fix(linter/no-unused-vars): false positives when variable and type have same name (#8465)

close: #8236
This commit is contained in:
Dunqing 2025-01-13 15:40:48 +00:00
parent 1d6e84dd33
commit 2be1e82964
2 changed files with 7 additions and 2 deletions

View file

@ -1083,7 +1083,10 @@ fn test_namespaces() {
#[test]
fn test_type_aliases() {
let pass = vec!["type Foo = string; export default Foo;"];
let pass = vec![
"type Foo = string; export default Foo;",
"const a = { hello: 'world' }; export type a = typeof a;",
];
let fail = vec![
// usages within own declaration do not count

View file

@ -291,7 +291,9 @@ impl<'a> Symbol<'_, 'a> {
| AstKind::ExportNamedDeclaration(_)
| AstKind::ExportDefaultDeclaration(_)
| AstKind::ExportAllDeclaration(_)
| AstKind::Program(_) => {
| AstKind::Program(_)
// It refers to value bindings, not types
| AstKind::TSTypeQuery(_) => {
return false;
}