tslib icon indicating copy to clipboard operation
tslib copied to clipboard

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

Open ExE-Boss opened this issue 5 years ago • 3 comments

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.

ExE-Boss avatar Jan 15 '20 06:01 ExE-Boss

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

HolgerJeromin avatar Jan 15 '20 07:01 HolgerJeromin

There should also be a change in TypeScript.

ExE-Boss avatar Jan 15 '20 07:01 ExE-Boss

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.

rbuckton avatar Feb 08 '22 17:02 rbuckton