Skip to content

fix(compiler): highlight type-reference names without template arguments - #12202

Open
Timothee Guerin (timotheeguerin) wants to merge 2 commits into
microsoft:mainfrom
timotheeguerin:fix/diagnostic-type-reference
Open

Timothee Guerin (timotheeguerin) wants to merge 2 commits into
microsoft:mainfrom
timotheeguerin:fix/diagnostic-type-reference

Conversation

@timotheeguerin

Copy link
Copy Markdown
Member

Diagnostics targeting a generic type reference currently underline all its template arguments, making the actual target harder to identify.

Narrow diagnostic highlights to the reference target: Foo<string> highlights Foo, and N.Foo<string> highlights N.Foo. Calls to getSourceLocation without locateId retain the full reference range.

Fixes #8087

@microsoft-github-policy-service microsoft-github-policy-service Bot added the compiler:core Issues for @typespec/compiler label Oct 15, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/compiler@12202

commit: bb2ea0d

@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @typespec/compiler
Show changes

@typespec/compiler - fix ✏️

Highlight type-reference names without their template arguments when reporting diagnostics.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused change matches the requested behavior, preserves default ranges, and includes targeted regression coverage.

0 open findings

What changed in this PR

Fixes #8087 by narrowing diagnostic highlights to type-reference names while preserving full ranges when locateId is omitted.

Changes:

  • Highlights Foo or N.Foo without template arguments.
  • Adds regression tests for default and narrowed ranges.
  • Documents the behavior and adds a compiler changelog entry.
File Description
packages/​compiler/​test/​core/​diagnostics.test.ts Tests default, simple, and qualified reference highlights.
packages/​compiler/​src/​core/​diagnostics.ts Narrows type-reference locations when locateId is enabled.
.chronus/​changes/​fix-diagnostic-type-reference-2026-9-15-11-16-18.md Records the compiler diagnostic fix.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@azure-sdk-automation

azure-sdk-automation Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:core Issues for @typespec/compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error targeting TypeReference node should only highlight the id

2 participants