Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 9, 2026

  • Understand the issue: When interpolating an invalid reference in a string template, both invalid-ref and non-literal-string-template errors are reported
  • Locate the code that reports non-literal-string-template error (in string-template-utils.ts)
  • Add check to skip reporting non-literal-string-template when the type is ErrorType
  • Add test case to verify the fix works
  • Run existing tests to ensure no regressions (all 3564 tests passed)
  • Verify the fix manually (confirmed only invalid-ref is shown for invalid references, and non-literal-string-template still appears for valid non-serializable types)
  • Run format and lint (all passed)
  • Add changeset for the fix
  • Address PR review feedback: Use isErrorType helper function instead of manual check
Original prompt

This section details on the original issue you should resolve

<issue_title>Interpolating an invalid reference include confusing error</issue_title>
<issue_description>```tsp
const b = "Some ${bad}";


invalid-ref Unknown identifier bad
non-literal-string-template Value interpolated in this string template cannot be converted to a string. Only literal types can be automatically interpolated.


[Playground Link](https://typespec.io/playground/?e=%40typespec%2Fopenapi3&options=%7B%7D&vs=%7B%7D&version=1.4.x&c=Y29uc3QgYiA9ICJTb21lICR7YmFkfSI7Cg%3D%3D)

`non-literal-string-template` should probably not be reported if the interpolated type is already an errorType</issue_description>

<agent_instructions>When reporting non-literal-string-template we should ignore ErrorType</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service bot added the compiler:core Issues for @typespec/compiler label Feb 9, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 9, 2026

Open in StackBlitz

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

commit: 2dc08be

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error reporting for non-literal string templates Fix: Don't report non-literal-string-template when interpolating ErrorType Feb 9, 2026
Copilot AI requested a review from timotheeguerin February 9, 2026 13:19
Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

All changed packages have been documented.

  • @typespec/compiler
Show changes

@typespec/compiler - fix ✏️

Don't report non-literal-string-template diagnostic when interpolating an invalid reference

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

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.

Interpolating an invalid reference include confusing error

3 participants