Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/oxc_isolated_declarations/src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions crates/oxc_isolated_declarations/tests/fixtures/typeof.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { ModA } from 'mod';
import { Variable } from 'constant';

export const Export: typeof ModA<typeof Variable> = 0;
10 changes: 10 additions & 0 deletions crates/oxc_isolated_declarations/tests/snapshots/typeof.snap
Original file line number Diff line number Diff line change
@@ -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