Skip to content

Commit 6ae178e

Browse files
committed
fix(linter): ignore type references in no-undef (#7670)
fixes #7007 fixes #7008
1 parent a0973dc commit 6ae178e

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

crates/oxc_linter/src/rules/eslint/no_undef.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ impl Rule for NoUndef {
5050
for reference_id_list in ctx.scopes().root_unresolved_references_ids() {
5151
for reference_id in reference_id_list {
5252
let reference = symbol_table.get_reference(reference_id);
53+
54+
if reference.is_type() {
55+
return;
56+
}
57+
5358
let name = ctx.semantic().reference_name(reference);
5459

5560
if ctx.env_contains_var(name) {
@@ -153,7 +158,9 @@ fn test() {
153158
"class C { static { function a() {} a; } }",
154159
"class C { static { a; function a() {} } }",
155160
"String;Array;Boolean;",
156-
"function resolve<T>(path: string): T { return { path } as T; }"
161+
"function resolve<T>(path: string): T { return { path } as T; }",
162+
"let xyz: NodeListOf<HTMLElement>",
163+
"type Foo = Record<string, unknown>;"
157164
];
158165

159166
let fail = vec![

0 commit comments

Comments
 (0)