zkat / proposal-as-patterns

`as` destructuring patterns
106 stars 2 forks source link

Problems #6

Open lifaon74 opened 6 years ago

lifaon74 commented 6 years ago

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).

zkat commented 6 years ago

@lifaon74 hey! Thanks for commenting

  1. 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.

  2. 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 :)