Skip to content

Commit 790a664

Browse files
committed
fix(semantic): track scope for TS construct signature type parameters
1 parent 7fedb92 commit 790a664

File tree

3 files changed

+44
-14
lines changed

3 files changed

+44
-14
lines changed
Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
/* should not generate diagnostics */
22

33
interface A {
4-
f(a: number);
5-
set a(a: number);
6-
[key: string]: string;
4+
f(a: number);
5+
set a(a: number);
6+
[key: string]: string;
7+
}
8+
9+
// Construct signature type members with generic parameters
10+
export interface Constructor {
11+
new <T>(): T;
12+
new <T>(value: T): T;
13+
}
14+
15+
export interface ConstructorWithMultipleOverloads {
16+
new <T>(): T;
17+
<T>(): T;
718
}
819

920
class B implements A {
10-
f(a: number) {console.log(a)}
11-
set a(a: number) {console.log(a)}
12-
[key: string]: string;
21+
f(a: number) {
22+
console.log(a);
23+
}
24+
set a(a: number) {
25+
console.log(a);
26+
}
27+
[key: string]: string;
1328
}
1429

1530
console.log(new B());

crates/biome_js_analyze/tests/specs/correctness/noUnusedVariables/validInterface.ts.snap

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,32 @@ expression: validInterface.ts
77
/* should not generate diagnostics */
88
99
interface A {
10-
f(a: number);
11-
set a(a: number);
12-
[key: string]: string;
10+
f(a: number);
11+
set a(a: number);
12+
[key: string]: string;
13+
}
14+
15+
// Construct signature type members with generic parameters
16+
export interface Constructor {
17+
new <T>(): T;
18+
new <T>(value: T): T;
19+
}
20+
21+
export interface ConstructorWithMultipleOverloads {
22+
new <T>(): T;
23+
<T>(): T;
1324
}
1425
1526
class B implements A {
16-
f(a: number) {console.log(a)}
17-
set a(a: number) {console.log(a)}
18-
[key: string]: string;
27+
f(a: number) {
28+
console.log(a);
29+
}
30+
set a(a: number) {
31+
console.log(a);
32+
}
33+
[key: string]: string;
1934
}
2035
2136
console.log(new B());
2237
2338
```
24-
25-

crates/biome_js_semantic/src/events.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ impl SemanticEventExtractor {
461461
| TS_DECLARE_FUNCTION_DECLARATION
462462
| TS_DECLARE_FUNCTION_EXPORT_DEFAULT_DECLARATION
463463
| TS_CALL_SIGNATURE_TYPE_MEMBER
464+
| TS_CONSTRUCT_SIGNATURE_TYPE_MEMBER
464465
| TS_METHOD_SIGNATURE_CLASS_MEMBER
465466
| TS_METHOD_SIGNATURE_TYPE_MEMBER
466467
| TS_INDEX_SIGNATURE_CLASS_MEMBER
@@ -866,6 +867,7 @@ impl SemanticEventExtractor {
866867
| TS_DECLARE_FUNCTION_DECLARATION
867868
| TS_DECLARE_FUNCTION_EXPORT_DEFAULT_DECLARATION
868869
| TS_CALL_SIGNATURE_TYPE_MEMBER
870+
| TS_CONSTRUCT_SIGNATURE_TYPE_MEMBER
869871
| TS_METHOD_SIGNATURE_CLASS_MEMBER
870872
| TS_METHOD_SIGNATURE_TYPE_MEMBER
871873
| TS_INDEX_SIGNATURE_CLASS_MEMBER

0 commit comments

Comments
 (0)