mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(isolated-declarations): declare global {} should be kept even if it is not exported (#3956)
close: #3952
This commit is contained in:
parent
15ec254740
commit
31e4c3b33e
4 changed files with 23 additions and 0 deletions
|
|
@ -824,6 +824,12 @@ pub enum TSModuleDeclarationKind {
|
|||
Namespace,
|
||||
}
|
||||
|
||||
impl TSModuleDeclarationKind {
|
||||
pub fn is_global(self) -> bool {
|
||||
matches!(self, TSModuleDeclarationKind::Global)
|
||||
}
|
||||
}
|
||||
|
||||
#[visited_node]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
|
|
|
|||
|
|
@ -142,6 +142,11 @@ impl<'a> IsolatedDeclarations<'a> {
|
|||
);
|
||||
variable_transformed_indexes.push_back(Vec::default());
|
||||
}
|
||||
Declaration::TSModuleDeclaration(decl) => {
|
||||
if decl.kind.is_global() {
|
||||
transformed_indexes.push(new_stmts.len());
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
new_stmts.push(stmt);
|
||||
|
|
|
|||
4
crates/oxc_isolated_declarations/tests/fixtures/declare-global.ts
vendored
Normal file
4
crates/oxc_isolated_declarations/tests/fixtures/declare-global.ts
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
declare global {
|
||||
}
|
||||
|
||||
export {}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/declare-global.ts
|
||||
---
|
||||
==================== .D.TS ====================
|
||||
|
||||
declare module global {}
|
||||
export {};
|
||||
Loading…
Reference in a new issue