From 790a66473dfad7732261295df73dd67231a89266 Mon Sep 17 00:00:00 2001 From: romano <229324643+ruidosujeira@users.noreply.github.com> Date: Mon, 15 Dec 2025 03:08:27 -0300 Subject: [PATCH 1/3] fix(semantic): track scope for TS construct signature type parameters --- .../noUnusedVariables/validInterface.ts | 27 +++++++++++++---- .../noUnusedVariables/validInterface.ts.snap | 29 ++++++++++++++----- crates/biome_js_semantic/src/events.rs | 2 ++ 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/crates/biome_js_analyze/tests/specs/correctness/noUnusedVariables/validInterface.ts b/crates/biome_js_analyze/tests/specs/correctness/noUnusedVariables/validInterface.ts index 85539f091aca..fd311ec0ac85 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/noUnusedVariables/validInterface.ts +++ b/crates/biome_js_analyze/tests/specs/correctness/noUnusedVariables/validInterface.ts @@ -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; + new (value: T): T; +} + +export interface ConstructorWithMultipleOverloads { + new (): 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()); diff --git a/crates/biome_js_analyze/tests/specs/correctness/noUnusedVariables/validInterface.ts.snap b/crates/biome_js_analyze/tests/specs/correctness/noUnusedVariables/validInterface.ts.snap index e13eb25c2453..fa25dc1b90f3 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/noUnusedVariables/validInterface.ts.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/noUnusedVariables/validInterface.ts.snap @@ -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; + new (value: T): T; +} + +export interface ConstructorWithMultipleOverloads { + new (): 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()); ``` - - diff --git a/crates/biome_js_semantic/src/events.rs b/crates/biome_js_semantic/src/events.rs index 0b6e01707531..398b178ced2d 100644 --- a/crates/biome_js_semantic/src/events.rs +++ b/crates/biome_js_semantic/src/events.rs @@ -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 @@ -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 From 657d8ddbb0a73c1d866d0f91700a5f6e84d50e13 Mon Sep 17 00:00:00 2001 From: romano <229324643+ruidosujeira@users.noreply.github.com> Date: Mon, 15 Dec 2025 03:15:38 -0300 Subject: [PATCH 2/3] add changeset --- .changeset/fix-construct-signature-unused-type-param.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-construct-signature-unused-type-param.md diff --git a/.changeset/fix-construct-signature-unused-type-param.md b/.changeset/fix-construct-signature-unused-type-param.md new file mode 100644 index 000000000000..78154449f38c --- /dev/null +++ b/.changeset/fix-construct-signature-unused-type-param.md @@ -0,0 +1,5 @@ +--- +"@biomejs/biome": patch +--- + +Fix [#8435](https://github.com/biomejs/biome/issues/8435): resolve false positive in `noUnusedVariables` for generic type parameters in construct signature type members (`new (): T`). From e6b1dc5adcee0bd5d7dd8af9b8abb4cb792c2be9 Mon Sep 17 00:00:00 2001 From: romano <229324643+ruidosujeira@users.noreply.github.com> Date: Mon, 15 Dec 2025 03:20:40 -0300 Subject: [PATCH 3/3] refactor changeset --- .changeset/fix-construct-signature-unused-type-param.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/fix-construct-signature-unused-type-param.md b/.changeset/fix-construct-signature-unused-type-param.md index 78154449f38c..e213d9709d4c 100644 --- a/.changeset/fix-construct-signature-unused-type-param.md +++ b/.changeset/fix-construct-signature-unused-type-param.md @@ -2,4 +2,4 @@ "@biomejs/biome": patch --- -Fix [#8435](https://github.com/biomejs/biome/issues/8435): resolve false positive in `noUnusedVariables` for generic type parameters in construct signature type members (`new (): T`). +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`).