Skip to content
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

verbatimModuleSyntax not work with namespace at top level #52461

Open
Jack-Works opened this issue Jan 27, 2023 · 3 comments
Open

verbatimModuleSyntax not work with namespace at top level #52461

Jack-Works opened this issue Jan 27, 2023 · 3 comments

Comments

@Jack-Works
Copy link
Contributor

Bug Report

verbatimModuleSyntax not work with namespace

πŸ”Ž Search Terms

verbatimModuleSyntax

πŸ•— Version & Regression Information

5.0.0-beta

⏯ Playground Link

N/A because need a package.json

πŸ’» Code

{
    "type": "module",
        "dependencies": {
                "typescript": "5.0.0-beta"
        }
}
export namespace T {
        export enum A { a = 1 }
}

npx tsc --moduleResolution NodeNext --module NodeNext --verbatimModuleSyntax .\index.mts

πŸ™ Actual behavior

index.mts:1:1 - error TS1287: A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled.

1 export namespace T {
  ~~~~~~


Found 1 error in index.mts:1

πŸ™‚ Expected behavior

works

@jakebailey
Copy link
Member

@DanielRosenwasser
Copy link
Member

The error is not the namespace, it is the use of a top-level export. I'd expect you need to write the following:

namespace T {
    export enum A { a = 1 }
}

export = {
    T
}

@DanielRosenwasser DanielRosenwasser changed the title verbatimModuleSyntax not work with namespace verbatimModuleSyntax not work with namespace at top level Jan 28, 2023
@DanielRosenwasser
Copy link
Member

Oh, but this is in a .mts file with "type": "module"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants