最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Which ECMAScript version to choose for TypeScript compiler in Electron app? - Stack Overflow

programmeradmin0浏览0评论

I am currently targeting es3 by default in my tsconfig.json file of my Electron 5.0.6 project. I get an error message that I have to upgrade to at least es6 to use the getter/setter functionality of TypeScript.

Now I am wondering how I should choose the right ECMAScript version for my project. I obviously want to use the newest features of ECMAScript but I don't know how upgrading to a newer version will change the platform support of my project. I still want to support older OS versions and want to know whether upgrading the ECMAScript target version affects this in some way or whether there is some other reason not to upgrade.

Please tell me if I have to add some more information to my question. I appreciate every answer.

I am currently targeting es3 by default in my tsconfig.json file of my Electron 5.0.6 project. I get an error message that I have to upgrade to at least es6 to use the getter/setter functionality of TypeScript.

Now I am wondering how I should choose the right ECMAScript version for my project. I obviously want to use the newest features of ECMAScript but I don't know how upgrading to a newer version will change the platform support of my project. I still want to support older OS versions and want to know whether upgrading the ECMAScript target version affects this in some way or whether there is some other reason not to upgrade.

Please tell me if I have to add some more information to my question. I appreciate every answer.

Share Improve this question asked Jul 16, 2019 at 17:35 user8393310user8393310 5
  • For Electron? ES2016 should be fine. – Kyle Commented Jul 16, 2019 at 17:43
  • Just check what V8 version your electron version uses in the release documentation or by this code. – Bergi Commented Jul 16, 2019 at 17:58
  • @Bergi and how does that help me determine the right ECMAScript version? I am unable to find out my V8 version ATM – user8393310 Commented Jul 16, 2019 at 20:48
  • In general, V8 supports the latest ECMAScript version out of the box, so feel free to use ES2019 for a recent Electron version. If you're not sure about a certain feature, check whether your V8 version supports it, or what V8 version you would need to get it. – Bergi Commented Jul 16, 2019 at 20:51
  • Electron includes its own browser, so you don't have to worry about users having old and outdated browsers, you certainly don't have to support ES3 (which is from 1999!) – Kokodoko Commented Jul 16, 2019 at 23:15
Add a ment  | 

1 Answer 1

Reset to default 9

You should target the supported ECMA version for your app. usually, I choose them based on the Chromium, Node and V8 version for a specific electron release.

Electron 5.0.7 uses Node v12.0.0 and Chromium 73 so its ES10/ES2019 patible. Based on these tables.

  • JSON Table of all the information related to an electron version

  • NodeJS(Main Process) ECMA features patibility list

  • Chromium(Render Process) ECMA features patibility list

Hint: Sometimes the main and render process support different specs, so always be sure to target the correct version for each process.

发布评论

评论列表(0)

  1. 暂无评论