Open lifaon74 opened 6 years ago
@lifaon74 hey! Thanks for commenting
I believe this covers a use case that is not easily achieved right now, at least for arrays, and is not very clear when working with objects. When people want to do things like these, they already need to do workarounds, and those workarounds may not be that clear to begin with.
I'm not concerned about this. The original idea for using as
, specifically, was @bterlson's, and I think he can speak pretty authoritatively about Typescript :)
I see 2 big issues:
1) The destructing begins to be more and more complex and even sometimes more complex than simple property access... => this allow developer to write really incomprehensible code for others. Adding more keywords/syntax on a language should be limited to the strictly necessary to avoid messy code and redondant syntax (different syntax to do exactly the same, without providing important benefits).
2) Typescript, probably used by millions of developers (2.6M download last 7 days - 12/04/2018]), already use the
as
keyword to "cast" variables (define the type). The proposed syntax could enter in conflict with it and may cause big trouble for many people...The
const {x: {y}, x} = {x: {y: 1}};
shown in https://github.com/zkat/proposal-as-patterns/issues/4 seems safer and easier to read/understand (and works in stric mode).