microsoft / tslib

Runtime library for TypeScript helpers.
BSD Zero Clause License
1.26k stars 128 forks source link

fix(__extends): Use correct behaviour with `null` prototype #85

Open ExE-Boss opened 4 years ago

ExE-Boss commented 4 years ago

If you were to call __extends(Foo, null), it would cause incorrect behaviour for extendStatics, as Foo is supposed to inherit from %Function.prototype% in that case, instead of also inheriting from null.

HolgerJeromin commented 4 years ago

Does this change relate to a change in Typescript? Or should there be a change there?

ExE-Boss commented 4 years ago

There should also be a change in TypeScript.

rbuckton commented 2 years ago

Apparently "correct" behavior when extending null is up for debate. The algorithms in the ECMA-262 specification related to extends null actually prevent it from working, and no engine currently supports extends null. The last time the behavior was discussed in plenary was last October and the conclusion was that more time is needed to explore solutions.

Until this has been resolved in the specification, I'd rather not make any more changes to extends null semantics in TypeScript. Until then, I plan to leave this PR open so that we can come back to it once the specification issues have been resolved.