Skip to content

"Extending expressions" feature in TypeScript 1.6 leads to inconsistent compiler behaviour. #4975

@lord-saumagen

Description

@lord-saumagen

"Extending expressions" feature in TypeScript 1.6 leads to inconsistent compiler behaviour.

Dear ladies and gentlemen,

I have a question regarding the compiler behaviour change for the new TypeScript 1.6 feature:
"Expression extending".

[Description at: https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript]
featuredescription

Before V1.6 I wasn't able to drive from the built-in classes and got a compiler error at design time.
The compiler simply didn't let me do it.

[compile-time error]
compilererror

Now I'm able to drive from the built-in classes and I'm very happy about that. But unfortunately that also has the effect that I don't get any warning when I'm going to derive from unsupported classes.
Here is an example where I drive from the "HTMLElement" class.
The compiler let me do that, but afterwards I get a runtime error.

[runtime error]
runtimeerror

The powerful error handling system of the TypeScript compiler is one of the features I like most. Before, I was able to make any stupid mistake in JavaScript and could only hope that such errors would reveal themselves at runtime. Hopefully before my code went into production. With the 1.6 release you relaxed the error handling system of the compiler. An error which was a compile-time error before became a runtime error with this release.

My question is, did you do that by purpose or was it an unpredicted side effect?

Before you ask, I'm aware that the "HTMLElement" class is not a built-in class but a WebAPI class. But before 1.6 I didn't have to worry about that in any way. WebAPI or built-in, the classes were all handled the same way.

I would appreciate if you could clarify that for me.

Kind regards, Lord Saumagen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions