Improve support for diagnostics from runtime compiler APIs (#3911)

- Exports diagnostic items from `diagnostics.ts` which are missing at
  runtime.
- Returns an array of diagnostics, instead of an object with a property
  of `items`.  This is because of the way Rust deals with certain
  structures, and shouldn't be exposed in the APIs.
This commit is contained in:
Kitson Kelly 2020-02-07 17:54:05 +11:00 committed by GitHub
parent 5a8ba3b114
commit ea6179f7dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 66 additions and 48 deletions

View file

@ -3,7 +3,7 @@
// This file contains the runtime APIs which will dispatch work to the internal
// compiler within Deno.
import { Diagnostic } from "./diagnostics.ts";
import { DiagnosticItem } from "./diagnostics.ts";
import * as dispatch from "./dispatch.ts";
import { sendAsync } from "./dispatch_json.ts";
import * as util from "./util.ts";
@ -328,7 +328,7 @@ export function compile(
rootName: string,
sources?: Record<string, string>,
options?: CompilerOptions
): Promise<[Diagnostic | undefined, Record<string, string>]> {
): Promise<[DiagnosticItem[] | undefined, Record<string, string>]> {
const payload = {
rootName: sources ? rootName : checkRelative(rootName),
sources,
@ -377,7 +377,7 @@ export function bundle(
rootName: string,
sources?: Record<string, string>,
options?: CompilerOptions
): Promise<[Diagnostic | undefined, string]> {
): Promise<[DiagnosticItem[] | undefined, string]> {
const payload = {
rootName: sources ? rootName : checkRelative(rootName),
sources,