From a5eb2dfc93afc2899ed6e1ad2b3e029157889f7c Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Tue, 22 Jun 2021 07:27:32 +1000 Subject: fix(#10761): graph errors reported as diagnostics for `Deno.emit()` (#10767) Fixes #10761 --- cli/tests/compiler_api_test.ts | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'cli/tests/compiler_api_test.ts') diff --git a/cli/tests/compiler_api_test.ts b/cli/tests/compiler_api_test.ts index b9a08d5ca..2e0a8820c 100644 --- a/cli/tests/compiler_api_test.ts +++ b/cli/tests/compiler_api_test.ts @@ -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", + ), + ); + }, +}); -- cgit v1.2.3