ECMAScript 6在对象解构中传播语法。支持TypeScript和Babel [英] ECMAScript 6 spread syntax in object deconstruction. Support in TypeScript and Babel

查看:363
本文介绍了ECMAScript 6在对象解构中传播语法。支持TypeScript和Babel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是否有效的ECMAScript 6?
似乎最新版本的Babel支持它,但它不是由TypeScript支持的。
我找不到处理此案例的任何ES6引用。

Is the following valid ECMAScript 6? It seems to be supported by the latest version of Babel but it isn't by TypeScript. I couldn't find any ES6 references dealing with this case.

var a = { foo : 'foo' };
var b = { ...a };


推荐答案

不,这不是有效的ECMAScript 6. ES6可以只支持函数参数和数组解构中的rest语法,并在函数调用和数组构造中扩展语法。

No, this is not valid ECMAScript 6. ES6 does only support rest syntax in function parameters and array destructuring, and spread syntax in function calls and array construction.


它似乎得到了支持最新版本的Babel

It seems to be supported by the latest version of Babel

Babel确实实现了 objectRestSpread ES7提案传播为实验性插件。您不应该使用此功能,它可能随时中断。

Babel does implement the objectRestSpread ES7 proposal as a experimental plugin. You shouldn't use this feature, it may break at any time.

这篇关于ECMAScript 6在对象解构中传播语法。支持TypeScript和Babel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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