Skip to content

fix(compiler): improve error message when --emit specifies an uninstalled emitter - #11485

Open
timotheeguerin with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-invalid-emitter-error-message
Open

fix(compiler): improve error message when --emit specifies an uninstalled emitter#11485
timotheeguerin with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-invalid-emitter-error-message

Conversation

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

tsp compile . --emit not-installed-emitter previously emitted a generic import-not-found error with no actionable guidance. It now reports a dedicated emitter-not-found diagnostic with an install hint.

Before:

error import-not-found: Couldn't resolve import "not-installed-emitter"

After:

error emitter-not-found: Emitter "not-installed-emitter" not found. Make sure to install it with `npm install not-installed-emitter`.

Changes

  • messages.ts: New emitter-not-found diagnostic code with a message that names the emitter and includes an npm install hint.
  • program.ts: loadLibrary accepts an optional { isEmitter } context flag; when set and the underlying error is import-not-found, it reports emitter-not-found instead. loadEmitter passes { isEmitter: true }.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

… emitter

When running `tsp compile . --emit not-installed-emitter`, the error message
now reports a more helpful `emitter-not-found` diagnostic with a suggestion
to install the package, instead of the generic `import-not-found` error.

Closes #1982

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error message for --emit invalid-emitter fix(compiler): improve error message when --emit specifies an uninstalled emitter Jul 30, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the compiler:core Issues for @typespec/compiler label Jul 30, 2026
Copilot AI requested a review from timotheeguerin July 30, 2026 16:21
@pkg-pr-new

pkg-pr-new Bot commented Jul 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 5315d23

@timotheeguerin
timotheeguerin marked this pull request as ready for review July 30, 2026 16:41
@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@timotheeguerin
timotheeguerin enabled auto-merge July 30, 2026 17:03
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.

--emit invalid-emitter doesn't give the best error message

2 participants