Skip to content

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

Open
timotheeguerin with Copilot wants to merge 4 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 4 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
npm i https://pkg.pr.new/@typespec/playground@11485

commit: 954f504

@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
@timotheeguerin

Copy link
Copy Markdown
Member

@copilot pull main and resolve conflicts

…mitter-error-message

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>

Copilot AI commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@copilot pull main and resolve conflicts

Done — merged main and resolved the conflict in emitter.test.ts (combined the createTypeSpecLibrary import from main with the expectDiagnostics import from our branch). All tests pass.

@timotheeguerin

Copy link
Copy Markdown
Member

@copilot one test is failing now ❯ test/deferred-emitter-compile.test.ts:109:51

…ound

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>

Copilot AI commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@copilot one test is failing now ❯ test/deferred-emitter-compile.test.ts:109:51

Fixed — updated packages/playground/test/deferred-emitter-compile.test.ts line 109 to expect emitter-not-found instead of import-not-found. Committed in the latest push.

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 ui:playground

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants