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
5 changes: 5 additions & 0 deletions .changeset/fix-construct-signature-unused-type-param.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@biomejs/biome": patch
---

Fix [#8435](https://github.com/biomejs/biome/issues/8435): resolved false positive in `noUnusedVariables` for generic type parameters in construct signature type members (`new <T>(): T`).
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
/* should not generate diagnostics */

interface A {
f(a: number);
set a(a: number);
[key: string]: string;
f(a: number);
set a(a: number);
[key: string]: string;
}

// Construct signature type members with generic parameters
export interface Constructor {
new <T>(): T;
new <T>(value: T): T;
}

export interface ConstructorWithMultipleOverloads {
new <T>(): T;
<T>(): T;
}

class B implements A {
f(a: number) {console.log(a)}
set a(a: number) {console.log(a)}
[key: string]: string;
f(a: number) {
console.log(a);
}
set a(a: number) {
console.log(a);
}
[key: string]: string;
}

console.log(new B());
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,32 @@ expression: validInterface.ts
/* should not generate diagnostics */

interface A {
f(a: number);
set a(a: number);
[key: string]: string;
f(a: number);
set a(a: number);
[key: string]: string;
}

// Construct signature type members with generic parameters
export interface Constructor {
new <T>(): T;
new <T>(value: T): T;
}

export interface ConstructorWithMultipleOverloads {
new <T>(): T;
<T>(): T;
}

class B implements A {
f(a: number) {console.log(a)}
set a(a: number) {console.log(a)}
[key: string]: string;
f(a: number) {
console.log(a);
}
set a(a: number) {
console.log(a);
}
[key: string]: string;
}

console.log(new B());

```


2 changes: 2 additions & 0 deletions crates/biome_js_semantic/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ impl SemanticEventExtractor {
| TS_DECLARE_FUNCTION_DECLARATION
| TS_DECLARE_FUNCTION_EXPORT_DEFAULT_DECLARATION
| TS_CALL_SIGNATURE_TYPE_MEMBER
| TS_CONSTRUCT_SIGNATURE_TYPE_MEMBER
| TS_METHOD_SIGNATURE_CLASS_MEMBER
| TS_METHOD_SIGNATURE_TYPE_MEMBER
| TS_INDEX_SIGNATURE_CLASS_MEMBER
Expand Down Expand Up @@ -866,6 +867,7 @@ impl SemanticEventExtractor {
| TS_DECLARE_FUNCTION_DECLARATION
| TS_DECLARE_FUNCTION_EXPORT_DEFAULT_DECLARATION
| TS_CALL_SIGNATURE_TYPE_MEMBER
| TS_CONSTRUCT_SIGNATURE_TYPE_MEMBER
| TS_METHOD_SIGNATURE_CLASS_MEMBER
| TS_METHOD_SIGNATURE_TYPE_MEMBER
| TS_INDEX_SIGNATURE_CLASS_MEMBER
Expand Down
Loading