-
-
Notifications
You must be signed in to change notification settings - Fork 791
fix(semantic): track scope for TS construct signature type parameters #8459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(semantic): track scope for TS construct signature type parameters #8459
Conversation
🦋 Changeset detectedLatest commit: e6b1dc5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughAdds support for construct signature type members in the semantic event extractor so an ambient scope is pushed on entering and popped on leaving Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1).changeset/*.md📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
🧠 Learnings (4)📓 Common learnings📚 Learning: 2025-08-05T14:43:29.581ZApplied to files:
📚 Learning: 2025-12-12T10:11:05.549ZApplied to files:
📚 Learning: 2025-09-25T12:32:59.003ZApplied to files:
🪛 LanguageTool.changeset/fix-construct-signature-unused-type-param.md[uncategorized] ~5-~5: The preposition ‘to’ seems more likely in this position. (AI_HYDRA_LEO_REPLACE_IN_TO) ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.changeset/fix-construct-signature-unused-type-param.md(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Write changesets that are concise (1-3 sentences), user-focused, use past tense for actions taken and present tense for Biome behavior, include code examples for rules, and end sentences with periods
Files:
.changeset/fix-construct-signature-unused-type-param.md
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use `Semantic<T>` query type instead of `Ast<T>` when a rule needs to access the semantic model for binding references and scope information
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Check if a variable is global before banning it to avoid false positives when the variable is redeclared in local scope; use the semantic model to verify global scope
📚 Learning: 2025-08-05T14:43:29.581Z
Learnt from: dyc3
Repo: biomejs/biome PR: 7081
File: packages/@biomejs/biome/configuration_schema.json:7765-7781
Timestamp: 2025-08-05T14:43:29.581Z
Learning: The file `packages/biomejs/biome/configuration_schema.json` is auto-generated and should not be manually edited or reviewed for schema issues; any changes should be made at the code generation source.
Applied to files:
.changeset/fix-construct-signature-unused-type-param.md
🪛 LanguageTool
.changeset/fix-construct-signature-unused-type-param.md
[uncategorized] ~5-~5: The preposition ‘to’ seems more likely in this position.
Context: ...dVariables for generic type parameters in construct signature type members (new ...
(AI_HYDRA_LEO_REPLACE_IN_TO)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
- GitHub Check: Documentation
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: End-to-end tests
- GitHub Check: Check Dependencies
- GitHub Check: Test Node.js API
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: autofix
- GitHub Check: Parser conformance
🔇 Additional comments (1)
.changeset/fix-construct-signature-unused-type-param.md (1)
1-5: Changeset structure looks good.The changeset is user-focused, concise, includes a relevant code example, and properly references the linked issue. Once the tense is corrected, this is ready to merge.
CodSpeed Performance ReportMerging #8459 will not alter performanceComparing Summary
Footnotes
|
dyc3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Summary
Fixes #8435
This PR fixes a false positive in
noUnusedVariableswhere type parameters in TypeScript construct signatures were incorrectly flagged as unused.Problem
The semantic model was not tracking scopes for
TS_CONSTRUCT_SIGNATURE_TYPE_MEMBERnodes. This caused type parameters in construct signatures likenew <T>(): Tto not be properly registered, leading the linter to report them as unused even though they were clearly used in the return type.Solution
Added
TS_CONSTRUCT_SIGNATURE_TYPE_MEMBERto the scope entry/exit events inevents.rs, ensuring that:noUnusedVariablesrule can accurately determine if they're actually usedThis is a minimal, fix that mirrors how other type member scopes are handled in the semantic model.
Test Plan
Added regression test in
validInterface.ts:This test verifies that:
Tis recognized as used in the return typeRan the full test suite to ensure no regressions in other areas.