-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Cannot 'export default' abstract, ambient class or interface #3792
Comments
In what situations would one need to make an ambient class a default export? |
These two are by desing. We have felt that the declare class C {}
export default C; |
We should just allow these. It's a strange inconsistency, the workaround is more verbose, and the error gives you no help getting to the workaround. |
Yeah, discussed with @danquirk and @RyanCavanaugh offline; in a I don't think it's that unreasonable to support the original syntax. |
should also cover interfaces (#3914): export default interface User {
wpUserID: string;
} |
And namespaces: |
Accepting PRs for this. |
Does this mean a namespace can be anonymous? export default namespace {
export var foo = 100;
} What about an interface? export default interface {
foo: number;
} |
No other changes except for allowing the |
I would prefer support for |
I'm OK with leaving it as is if the reasoning is that interfaces, et al, are not vaid EcmaScript and #3917 is implemented. |
Unsupported
|
@mhegazy what about |
@mhegazy for full symmetry with JS export forms, consider (strawman syntax)
|
not sure what that means.. export default as number but if it is a .d.ts, we chose not to have a special syntax for this, and the recommendation here is to use declare cosnt _t: number;
export default _t; |
Yeah, sorry, it is a bit ambiguous. Currently, you can sort of export a type as default with: type T = number;
export default T; By analogy of export const x = 123;
export type T = number;
export default x;
export default T;
export default 123;
export default ???; // can't put type expressions here, only type names, due to ambiguity The motivating case would would be something like: // Action.ts
export default as
| { type: 'login', name: string, password: string }
| { type: 'logout' }
| ... where currently you would need to bury the export at the bottom of the file. I picked |
…icrosoft#3792 (comment). Added corresponding tests. NB: export defaults are not yet transformed correctly.
covers - "[abstract] class" - interfaces as per microsoft/TypeScript#3792 (comment) in 2020/12/15 other constructs (microsoft/TypeScript#18628 (comment)) are not yet supported by TypeScript itself
covers - "[abstract] class" - interfaces as per microsoft/TypeScript#3792 (comment) in 2020/12/15 other constructs (microsoft/TypeScript#18628 (comment)) are not yet supported by TypeScript itself
covers - "[abstract] class" - interfaces as per microsoft/TypeScript#3792 (comment) in 2020/12/15 other constructs (microsoft/TypeScript#18628 (comment)) are not yet supported by TypeScript itself
covers - "[abstract] class" - interfaces as per microsoft/TypeScript#3792 (comment) in 2020/12/15 other constructs (microsoft/TypeScript#18628 (comment)) are not yet supported by TypeScript itself
covers - "[abstract] class" - interfaces as per microsoft/TypeScript#3792 (comment) in 2020/12/15 other constructs (microsoft/TypeScript#18628 (comment)) are not yet supported by TypeScript itself
Found this when trying |
By the way, the same with
Seems to be a parser bug
The text was updated successfully, but these errors were encountered: