mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(isolated-declarations): import statement disappears when import binding is referenced in nested typeof (#8476)
close: #8474
This commit is contained in:
parent
7252cb0d77
commit
7ee7634f1e
3 changed files with 20 additions and 0 deletions
|
|
@ -110,10 +110,16 @@ impl<'a> Visit<'a> for ScopeTree<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
// `typeof Value` or `typeof Value<Parameters>`
|
||||
fn visit_ts_type_query(&mut self, ty: &TSTypeQuery<'a>) {
|
||||
if let Some(type_name) = ty.expr_name.as_ts_type_name() {
|
||||
let ident = TSTypeName::get_identifier_reference(type_name);
|
||||
self.add_reference(ident.name.clone(), KindFlags::Value);
|
||||
// `typeof Type<Parameters>`
|
||||
// ^^^^^^^^^^^
|
||||
if let Some(type_parameters) = &ty.type_parameters {
|
||||
self.visit_ts_type_parameter_instantiation(type_parameters);
|
||||
}
|
||||
} else {
|
||||
walk_ts_type_query(self, ty);
|
||||
}
|
||||
|
|
|
|||
4
crates/oxc_isolated_declarations/tests/fixtures/typeof.ts
vendored
Normal file
4
crates/oxc_isolated_declarations/tests/fixtures/typeof.ts
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import { ModA } from 'mod';
|
||||
import { Variable } from 'constant';
|
||||
|
||||
export const Export: typeof ModA<typeof Variable> = 0;
|
||||
10
crates/oxc_isolated_declarations/tests/snapshots/typeof.snap
Normal file
10
crates/oxc_isolated_declarations/tests/snapshots/typeof.snap
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/typeof.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
import { ModA } from "mod";
|
||||
import { Variable } from "constant";
|
||||
export declare const Export: typeof ModA<typeof Variable>;
|
||||
Loading…
Reference in a new issue