Skip to content

Commit

Permalink
fix(linter): ignore type references in no-undef (#7670)
Browse files Browse the repository at this point in the history
fixes #7007
fixes #7008
  • Loading branch information
Boshen committed Dec 5, 2024
1 parent a0973dc commit 6ae178e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/oxc_linter/src/rules/eslint/no_undef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ impl Rule for NoUndef {
for reference_id_list in ctx.scopes().root_unresolved_references_ids() {
for reference_id in reference_id_list {
let reference = symbol_table.get_reference(reference_id);

if reference.is_type() {
return;
}

let name = ctx.semantic().reference_name(reference);

if ctx.env_contains_var(name) {
Expand Down Expand Up @@ -153,7 +158,9 @@ fn test() {
"class C { static { function a() {} a; } }",
"class C { static { a; function a() {} } }",
"String;Array;Boolean;",
"function resolve<T>(path: string): T { return { path } as T; }"
"function resolve<T>(path: string): T { return { path } as T; }",
"let xyz: NodeListOf<HTMLElement>",
"type Foo = Record<string, unknown>;"
];

let fail = vec![
Expand Down

0 comments on commit 6ae178e

Please sign in to comment.