fix(isolated-declarations): if declarations is referenced in declare global then keep it (#3982)

close: #3981
This commit is contained in:
Dunqing 2024-06-30 11:34:04 +00:00
parent 211447559b
commit bd1141da67
3 changed files with 14 additions and 1 deletions

View file

@ -144,6 +144,7 @@ impl<'a> IsolatedDeclarations<'a> {
}
Declaration::TSModuleDeclaration(decl) => {
if decl.kind.is_global() {
self.scope.visit_ts_module_declaration(decl);
transformed_indexes.push(new_stmts.len());
}
}

View file

@ -1,4 +1,11 @@
function MyFunction() {
return 'here is my function'
}
declare global {
interface Window {
MyFunction: typeof MyFunction
}
}
export {}

View file

@ -4,5 +4,10 @@ input_file: crates/oxc_isolated_declarations/tests/fixtures/declare-global.ts
---
==================== .D.TS ====================
declare global {}
declare function MyFunction(): string;
declare global {
interface Window {
MyFunction: typeof MyFunction;
}
}
export {};