Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Typescript 会支持类似于 CoffeeScript 的解构赋值吗?
foo = {x: 1, y: 2, z: 3} {x, z} = foo # which will yield x == 1 && z == 3
是的,它会。
在他们的错误跟踪器中看到这个问题:http: //typescript.codeplex.com/workitem/15
UPDATE:现在支持此功能。
UPDATE:
是的,它现在支持从 ES6 开始。您可以在浏览器(支持 ES6)控制台本身中测试代码,如下所示。
const user = {name: 'Robkuz', gender: 'Male', looks: 'Great'} const {name, looks} = user;