fix(no-implicit-declare-namespace-export): skip declare global#1485
Open
fibibot wants to merge 1 commit into
Open
fix(no-implicit-declare-namespace-export): skip declare global#1485fibibot wants to merge 1 commit into
declare global#1485fibibot wants to merge 1 commit into
Conversation
`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.
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
declare global { ... }is a module augmentation, and TypeScript rejects bothexport {}andexport { ... }inside one (TS2669 / "Exports and export assignments are not permitted in module augmentations").no-implicit-declare-namespace-exportrule fires on adeclare globalblock and suggestsexport {};, but following that hint swaps the warning for a real TypeScript compile error — so the rule just makesdeclare globalaugmentations unlintable without an ignore pragma.TsModuleDeclnodes wheremodule_decl.inner.globalis true (SWC's flag fordeclare global).Refs denoland/deno#33268.
Repro (before this PR)
Test plan
use_explicit_namespace_export_validwith twodeclare global { ... }fixtures (one with aconst, one withinterface+const). Verified they fail the previous assertion and pass with this change.cargo test no_implicit_declare_namespace_exportclean.cargo testfull suite clean.deno run --allow-run ./tools/format.ts --checkclean.