fix(isolated_declarations): Always emit module declarations (#4911)

Fixes https://github.com/oxc-project/oxc/issues/4607

Co-authored-by: MichaelMitchell-at <=>
This commit is contained in:
michaelm 2024-08-15 10:13:32 -04:00 committed by GitHub
parent 4a16916887
commit 0fb0b71f0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 0 deletions

View file

@ -314,6 +314,9 @@ impl<'a> IsolatedDeclarations<'a> {
new_ast_stmts.push(Statement::ImportDeclaration(decl));
}
}
Statement::TSModuleDeclaration(decl) => {
new_ast_stmts.push(Statement::TSModuleDeclaration(decl));
}
_ => {}
}
}

View file

@ -0,0 +1,5 @@
import 'foo';
declare module 'foo' {
interface Foo {}
const foo = 42;
}

View file

@ -0,0 +1,12 @@
---
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;
}
export {};