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

Option to error on module namespaces #10017

Closed
robpalme opened this issue Feb 9, 2025 · 0 comments · Fixed by #10022
Closed

Option to error on module namespaces #10017

robpalme opened this issue Feb 9, 2025 · 0 comments · Fixed by #10022
Assignees
Milestone

Comments

@robpalme
Copy link

robpalme commented Feb 9, 2025

Describe the feature

This feature request is motivated by Node's TypeScript integration. See nodejs/amaro#168 for the backstory.

The request is for SWC to introduce a TypeScript-specific option (example: no_module_keyword_for_ts_namespace) to error when the source text includes any form of namespace using the legacy module keyword:

  • module Foo {}
  • declare module Foo {}

This applies to both the ambient and non-ambient forms. And applies to both instantiated and uninstantiated forms.

Babel plugin or link to the feature description

nodejs/amaro#168

Additional context

Exclusions

Ambient module declarations (declare module "specifier" {}) are fine and should continue to be erased and not error.

Amaro Usage

The initial user of this feature will be Amaro in Node. Node needs to be able to show a helpful message to the user. The returned error should identify this specific error so that we can display a human-readable message such as:

module keyword is not supported. Use namespace instead.

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

Successfully merging a pull request may close this issue.

3 participants