Skip to content

Conversation

@mzhongl524
Copy link
Member

Fix: #8539.

show NoTarget diagnostic message in vscode

@mzhongl524 mzhongl524 added the ide Issues for VS, VSCode, Monaco, etc. label Oct 17, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the compiler:core Issues for @typespec/compiler label Oct 17, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 17, 2025

Open in StackBlitz

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

commit: 86040f0

@github-actions
Copy link
Contributor

github-actions bot commented Oct 17, 2025

All changed packages have been documented.

  • @typespec/compiler
Show changes

@typespec/compiler - fix ✏️

Show NoTarget diagnostic message in vscode

emitterName: string | undefined = undefined,
): Promise<VSLocation | typeof NoTarget | undefined> {
if (configFilePath && emitterName && emitterName.length > 0 && location === undefined) {
const [yamlScript] = parseYaml(await NodeSystemHost.readFile(configFilePath));
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to load the yaml here? I think we did the same thing for the import error in tspconfig.yaml but didn't need this change.

diagnostic: Diagnostic,
): [VSDiagnostic, TextDocument][] {
const root = getVSLocation(
emitters?: string[] | undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

emitters is confusing here, better to pass in the settings directly

if (root === NoTarget) {
let customMsg = "";
if (emitters && emitters.includes(emitterName || "")) {
customMsg = ". It's configured in vscode settings.";
Copy link
Contributor

Choose a reason for hiding this comment

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

" [...]", ". " may not be correct because you dont know the original message

let customMsg = "";
if (emitters && emitters.includes(emitterName || "")) {
customMsg = ". It's configured in vscode settings.";
}
Copy link
Contributor

Choose a reason for hiding this comment

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

else {
... [No target source location reported for this Error/Warning]
}

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 ide Issues for VS, VSCode, Monaco, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ide] misconfigured emiter in vscode won't be reported in vscode and it will also block the linter rules to run silently

2 participants