-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extending a short hand ambient module import #12971
Comments
this is the same as: var a: any;
class C extends a {} the type system does not know what extending you can cast to a class/constructor function if you need to e.g. declare class B { }
const constructor = a as typeof B;
class C extends constructor {
} or just define the class on the module. |
@mhegazy Those solutions are all very verbose when declaring many modules as an interim step in converting a large javascript codebase. It would be better to have the short hand module declaration export a more inclusive import * as Base from 'base';
const base = new Base(); |
In my experience this is a huge point of friction for JavaScript teams working on existing code-bases dipping their toes into the statically typed world. They're almost immediately hit with the need to:
It would be great if instead extending an any type worked.
I'd be fine with the class being an any. |
TypeScript Version: 2.1.1
Code
Expected behavior:
An easy concise way of declaring a module so that the base import can be extended
Actual behavior:
error TS2507: Type 'any' is not a constructor function type.
In order to get around the error, I have to do something like this:
The text was updated successfully, but these errors were encountered: