Question

Will Typescript support destructuring assignments similar to CoffeeScript?

 foo = {x: 1, y: 2, z: 3}
 {x, z} = foo

 # which will yield
 x == 1 && z == 3
Was it helpful?

Solution

Yes, it will.

See this issue in their bug tracker: http://typescript.codeplex.com/workitem/15

UPDATE: This is now supported.

OTHER TIPS

Yeah it now support from ES6 onwards. You can test the code in your browser(which supports ES6) console itself as below.

const user = {name: 'Robkuz', gender: 'Male', looks: 'Great'}
const {name, looks} = user;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top