diff --git a/crates/oxc_isolated_declarations/src/scope.rs b/crates/oxc_isolated_declarations/src/scope.rs index 7c4d181b548db..0da8c92a54b09 100644 --- a/crates/oxc_isolated_declarations/src/scope.rs +++ b/crates/oxc_isolated_declarations/src/scope.rs @@ -110,10 +110,16 @@ impl<'a> Visit<'a> for ScopeTree<'a> { } } + // `typeof Value` or `typeof Value` 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` + // ^^^^^^^^^^^ + if let Some(type_parameters) = &ty.type_parameters { + self.visit_ts_type_parameter_instantiation(type_parameters); + } } else { walk_ts_type_query(self, ty); } diff --git a/crates/oxc_isolated_declarations/tests/fixtures/typeof.ts b/crates/oxc_isolated_declarations/tests/fixtures/typeof.ts new file mode 100644 index 0000000000000..d78055c781d09 --- /dev/null +++ b/crates/oxc_isolated_declarations/tests/fixtures/typeof.ts @@ -0,0 +1,4 @@ +import { ModA } from 'mod'; +import { Variable } from 'constant'; + +export const Export: typeof ModA = 0; diff --git a/crates/oxc_isolated_declarations/tests/snapshots/typeof.snap b/crates/oxc_isolated_declarations/tests/snapshots/typeof.snap new file mode 100644 index 0000000000000..e921a1e76e921 --- /dev/null +++ b/crates/oxc_isolated_declarations/tests/snapshots/typeof.snap @@ -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;