在ECMA的第3阶段使用提案在统计上是否安全? [英] Is it statistically safe to use proposals in Stage 3 of ECMA?

查看:51
本文介绍了在ECMA的第3阶段使用提案在统计上是否安全?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我指的是 ... 运算符.许多人喜欢并支持执行以下操作的想法:

I am referring to the ... operator. Many people like and support the idea of doing the following:

const obj = { "hello": 1 };
const obj2 = { "world": 2, ...obj };

问题

我个人喜欢这种语法,而不是典型的 Object.assign ,但是最近在我开始在项目中使用它时,出现了eslint错误:

Problem

I personally like this syntax over the typical Object.assign but recently when I started using it in my project I had this eslint error:

对象传播-分析错误:意外的令牌

对此的解决方案可以在以下链接中找到:

The solution to this can be seen in the following links:

这里的问题是,要使用这种语法,我们需要在eslint上启用 experimentalObjectRestSpread 标志.该标志伴随以下警告:

The problem here is that to use such syntax we need to enable the experimentalObjectRestSpread flag on eslint. This flag is accompanied by the following warning:

experimentalObjectRestSpread-支持对实验对象的休息/扩散属性的支持(重要提示:这是一项实验功能,将来可能会发生重大变化.建议您不要编写依赖此功能的规则,除非您愿意进行维护成本).

experimentalObjectRestSpread - enable support for the experimental object rest/spread properties (IMPORTANT: This is an experimental feature that may change significantly in the future. It’s recommended that you do not write rules relying on this functionality unless you are willing to incur maintenance cost when it changes.)

在验证提案后,我意识到它处于阶段3: https://github.com/tc39/proposal-object-rest-spread

After verifying the proposal I realised it is in Stage 3: https://github.com/tc39/proposal-object-rest-spread

有关不同阶段的更多信息,请参见此处:

More information on the different stages can be seen here:

  • S3中向后兼容性更改的可能性是什么?
  • 在S3撤回了多少个提案?

推荐答案

S3中向后兼容性更改的可能性是什么?

What are probabilities of backwards compatibility changes in S3?

低而没有返回到第2阶段(请参阅下一个问题).

Low without returning to Stage 2 (see next question).

在S3撤回了多少个提案?

How many proposals have been withdrawn at S3 ?

这很罕见,但是确实发生了.例如,装饰器处于第3阶段,但已回滚到第2阶段.,则类字段在Stage 3处,但在11月又移回Stage 2(此后再次分裂,其中

It's rare, but it does happen. For instance, decorators was Stage 3 for some time but has been rolled back to Stage 2. Similarly, class fields were at Stage 3 but moved back to Stage 2 in November (and have since been split [again], where the Class Public Instance Fields & Private Instance Fields proposal went back to Stage 3 again, leaving Static class fields and private static methods at Stage 2).

通过查看历史记录,您可以了解事物的发展方式 https://github.com/tc39/proposals .不过,这可能会有些痛苦.

You can get an idea of how things move by reviewing the history on the README.md for https://github.com/tc39/proposals. It can be a bit of a pain, though.

在ECMA的第3阶段使用提案在统计上安全吗?

Is it statistically safe to use proposals in Stage 3 of ECMA?

这取决于您所说的统计上安全"的含义.如果您想要高度确定性,请限制自己进入阶段4.

It depends on what you mean by "statistically safe." If you want a high degree of certainty, restrict yourself to Stage 4.

特别是关于对象的停留/传播,它是在Chrome发行的当前V8版本和Firefox发行的SpiderMonkey中实现的(不是在标志后面).在这里尝试:

Specifically in regard to object rest/spread, it's implemented (not behind a flag) in current versions of V8 shipping in Chrome and SpiderMonkey shipping in Firefox. Try it here:

const a = {answer: 42};
const b = {question: "Life, the Universe, and Everything", ...a};
console.log(b);

第一天在11月的TC39会议上,状态更新为:

On the first day of the TC39 meeting in November, the status update was:

KCL:是否可以传播对象使其进入es2018?

KCL: Is Object spread possible to make it into es2018?

BT:如果有人可以进行PR并将其列入一月份的议程,那么我们可以将其放入.

BT: If someone can make a PR and get it on the January agenda then we can put it in.

...听起来可能在一月的第4阶段.

...which sounds like Stage 4 in January is likely.

这篇关于在ECMA的第3阶段使用提案在统计上是否安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆