fix(#10761): graph errors reported as diagnostics for Deno.emit() (#10767)

Fixes #10761
This commit is contained in:
Kitson Kelly 2021-06-22 07:27:32 +10:00 committed by GitHub
parent 281c4cd8fc
commit a5eb2dfc93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 88 additions and 7 deletions

View file

@ -456,3 +456,49 @@ Deno.test({
assert(files["deno:///bundle.js.map"]);
},
});
Deno.test({
name: `Deno.emit() - graph errors as diagnostics`,
ignore: Deno.build.os === "windows",
async fn() {
const { diagnostics } = await Deno.emit("/a.ts", {
sources: {
"/a.ts": `import { b } from "./b.ts";
console.log(b);`,
},
});
assert(diagnostics);
assertEquals(diagnostics, [
{
category: 1,
code: 2305,
start: { line: 0, character: 9 },
end: { line: 0, character: 10 },
messageText:
`Module '"deno:///missing_dependency.d.ts"' has no exported member 'b'.`,
messageChain: null,
source: null,
sourceLine: 'import { b } from "./b.ts";',
fileName: "file:///a.ts",
relatedInformation: null,
},
{
category: 1,
code: 900001,
start: null,
end: null,
messageText: "Unable to find specifier in sources: file:///b.ts",
messageChain: null,
source: null,
sourceLine: null,
fileName: "file:///b.ts",
relatedInformation: null,
},
]);
assert(
Deno.formatDiagnostics(diagnostics).includes(
"Unable to find specifier in sources: file:///b.ts",
),
);
},
});