mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(isolated_declarations): Always emit module declarations that perform augmentation (#4919)
Fixes https://github.com/oxc-project/oxc/issues/4607 Co-authored-by: MichaelMitchell-at <=>
This commit is contained in:
parent
1eb59d2b5e
commit
b3ec9e50bd
3 changed files with 41 additions and 0 deletions
|
|
@ -325,6 +325,11 @@ impl<'a> IsolatedDeclarations<'a> {
|
|||
new_ast_stmts.push(Statement::ImportDeclaration(decl));
|
||||
}
|
||||
}
|
||||
Statement::TSModuleDeclaration(decl) => {
|
||||
if decl.kind.is_global() || decl.id.is_string_literal() {
|
||||
new_ast_stmts.push(Statement::TSModuleDeclaration(decl));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
21
crates/oxc_isolated_declarations/tests/fixtures/module-declaration.ts
vendored
Normal file
21
crates/oxc_isolated_declarations/tests/fixtures/module-declaration.ts
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import 'foo';
|
||||
declare module 'foo' {
|
||||
interface Foo {}
|
||||
const foo = 42;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Bar {}
|
||||
const bar = 42 ;
|
||||
}
|
||||
|
||||
// should not be emitted
|
||||
module baz {
|
||||
interface Baz {}
|
||||
const baz = 42;
|
||||
}
|
||||
|
||||
declare module x {
|
||||
interface Qux {}
|
||||
const qux = 42;
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/module-declaration.ts
|
||||
---
|
||||
==================== .D.TS ====================
|
||||
|
||||
import "foo";
|
||||
declare module "foo" {
|
||||
interface Foo {}
|
||||
const foo = 42;
|
||||
}
|
||||
declare global {
|
||||
interface Bar {}
|
||||
const bar = 42;
|
||||
}
|
||||
Loading…
Reference in a new issue