-
Notifications
You must be signed in to change notification settings - Fork 12.8k
The export default interface
is allowed with verbatimModuleSyntax
enabled
#57518
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
Comments
Related: #41409 Maybe it's just because we don't have the |
I'm not sure. But by the error message, I guess, the compiler expects that the exported symbol is a value. I think the tsc should output an error if we could use |
This is a bit subtle, but itβs working as designed. The goal with |
This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
It is not clear in that case what the 'correct' way of dealing with this is? If I follow a 'one interface declaration' by file approach: interface IMyInterface {
// interface props
} Then none of these work: export default IMyInterface;
export IMyInterface;
export { IMyInterface };
export default type IMediaItem; I feel like I am forced to use the BTW If I can track down an answer, I'll provide it here. |
export default interface IMyInterface {
// interface props
} and interface IMyInterface {
// interface props
}
export type { IMyInterface as default }; are two verbatimModuleSyntax-compatible ways of default-exporting an interface. |
Given that this works: export default interface Intf {} Shouldnβt either one of the following work too? Why should interfaces get special syntactic treatment? export default type MyType = {};
export default type SomeOtherType; |
Iβm guessing because export default type
MyType = {};
export default type
SomeOtherType; |
π Search Terms
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?target=99&noImplicitReturns=false&alwaysStrict=false&noImplicitThis=false&strictPropertyInitialization=false&strictBindCallApply=false&strictFunctionTypes=false&strictNullChecks=false&noImplicitAny=false&ts=5.5.0-dev.20240224&esModuleInterop=false&declaration=false&jsx=0&verbatimModuleSyntax=true&allowSyntheticDefaultImports=false#code/KYDwDg9gTgLgBAE2AMwIYFcA28CWA7GYKNAY2DgEk4BvAXyA
π» Code
π Actual behavior
The compiler allows
export default interface I {}
withverbatimModuleSyntax
enabled.π Expected behavior
When we try to export an interface separately with the definition and
export default
syntax, thetsc
outputs an error.We can export an interface with
export default interface I {...}
even if the exported name does not reference a value, it references an interface. I have no idea whether the tsc should output an error in that case since I cannot found such case in the test. I think it can either be an error or needs to update the error message.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: