TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

The `export default interface` is allowed with `verbatimModuleSyntax` enabled

Open ueokande opened this issue 1 year ago • 0 comments

🔎 Search Terms

  • verbatimModuleSyntax
  • export default interface

🕗 Version & Regression Information

  • I can reproduce on v5.0.4 and the nightly version.

⏯ 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

export default interface I {}

🙁 Actual behavior

The compiler allows export default interface I {} with verbatimModuleSyntax enabled.

🙂 Expected behavior

When we try to export an interface separately with the definition and export default syntax, the tsc outputs an error.

interface I {}
export default I
An 'export default' must reference a value when 'verbatimModuleSyntax' is enabled, but 'I' only refers to a type.

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

ueokande avatar Feb 24 '24 10:02 ueokande