Skip to content

fix(no-implicit-declare-namespace-export): skip declare global#1485

Open
fibibot wants to merge 1 commit into
denoland:mainfrom
fibibot:fix/no-implicit-declare-namespace-export-declare-global
Open

fix(no-implicit-declare-namespace-export): skip declare global#1485
fibibot wants to merge 1 commit into
denoland:mainfrom
fibibot:fix/no-implicit-declare-namespace-export-declare-global

Conversation

@fibibot

@fibibot fibibot commented Apr 24, 2026

Copy link
Copy Markdown

Summary

  • declare global { ... } is a module augmentation, and TypeScript rejects both export {} and export { ... } inside one (TS2669 / "Exports and export assignments are not permitted in module augmentations").
  • The current no-implicit-declare-namespace-export rule fires on a declare global block and suggests export {};, but following that hint swaps the warning for a real TypeScript compile error — so the rule just makes declare global augmentations unlintable without an ignore pragma.
  • Skip TsModuleDecl nodes where module_decl.inner.global is true (SWC's flag for declare global).

Refs denoland/deno#33268.

Repro (before this PR)

// error: Implicit exports in ambient namespaces are discouraged to use
//   Try adding an `export {};` to the top of the namespace to disable this behavior
declare global {
  const asdf: number;
}

// Following the hint just creates a TypeScript error:
declare global {
  export {};   // TS2669: Exports and export assignments are not permitted in module augmentations.
  const asdf: number;
}

Test plan

  • Extended use_explicit_namespace_export_valid with two declare global { ... } fixtures (one with a const, one with interface + const). Verified they fail the previous assertion and pass with this change.
  • cargo test no_implicit_declare_namespace_export clean.
  • cargo test full suite clean.
  • deno run --allow-run ./tools/format.ts --check clean.

`declare global { ... }` is a module augmentation, and TypeScript rejects
`export {}` / `export { ... }` inside one ("Exports and export assignments
are not permitted in module augmentations"). Following this rule's hint
therefore produced a hard error — the rule has to skip `declare global`
blocks instead of suggesting a syntax that is illegal there.

Refs denoland/deno#33268.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Successfully merging this pull request may close these issues.

2 participants