Skip to content

The export default interface is allowed with verbatimModuleSyntax enabled Β #57518

Closed as not planned
@ueokande

Description

@ueokande

πŸ”Ž 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions