My point was that ES classes work as spec'd TypeScript classes are broken
without warning.

It's also not a matter of smelly instanceof, the problem is that if you add
a method to that list class it won't be there. The returned instance/object
won't have anything to do with the List class so classes in the well
defined TypeScript language are not even close to native JS.

Babel bug is well known and I've proposed already a fix and I've also
opened the currently opened bug about it.

Although Babel doesn't claim to be a well defined language, it's just a
transpiler, hence my nitpick on the TS description.

About frameworks or Angular, version 1 was based on eval and I think
frameworks should have an OK from TC39 before being considered influential .

TBH, I'd love to have an official review channel for hacky practices used
on frameworks, no matter how big is their company size, and flag officially
as TC39 friendly.

No idea if there are resources to do that, though, so I'm just speaking out
loudly.

Regards

On Sat, 22 Jul 2017 at 16:48, T.J. Crowder <tj.crow...@farsightsoftware.com>
wrote:

> On Sat, Jul 22, 2017 at 3:17 PM, Andrea Giammarchi <
> andrea.giammar...@gmail.com> wrote:
>
>> ```js
>> class List extends Array { }
>>
>> console.log(new List instanceof List);
>> // false .. seriously
>> ```
>>
>> Try it yourself. [1]
>>
>
> I don't have a horse in the TypeScript race, but that example is unfair:
> The playground targets ES5 by default. As you know, you can't correctly
> subclass Array with ES5 features. To get the expected `instanceof` result
> from that code in ES5-land, TypeScript would have to replace uses of
> `instanceof` with something of its own, sacrificing efficiency for a
> questionable gain (`instanceof` usually smells anyway). (It *is*
> unfortunate that http://www.typescriptlang.org/docs/handbook/classes.html
> doesn't mention this.)
>
> But ES5 output is just an option; if you tell TypeScript to output ES2015
> code instead (`tsc --target ES2015 example.ts`), you get the expected
> result. Note that Babel targeting ES5 output also outputs "false":
> https://goo.gl/aJuQjV (that's just a shortened version of the Babel link
> resulting from pasting the code above into https://babeljs.io/repl)
>
> If necessary, let's have a reasonable discussion of whether TypeScript's
> co-opting of keywords and syntax has a negative effect on the evolution of
> JavaScript (if that's a useful conversation to have), but let's not blame
> TypeScript for ES5's deficiencies, particularly not ones that were fixed
> more than two years ago.
>
>
> -- T.J. Crowder
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to