Skip to content

Commit

Permalink
fix(isolated-declarations): if declarations is referenced in `declare…
Browse files Browse the repository at this point in the history
… global` then keep it (#3982)

close: #3981
  • Loading branch information
Dunqing committed Jun 30, 2024
1 parent 2114475 commit bd1141d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/oxc_isolated_declarations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
function MyFunction() {
return 'here is my function'
}

declare global {
interface Window {
MyFunction: typeof MyFunction
}
}

export {}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};

0 comments on commit bd1141d

Please sign in to comment.