summaryrefslogtreecommitdiff
path: root/js/compiler.ts
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2018-09-06 09:34:25 -0700
committerRyan Dahl <ry@tinyclouds.org>2018-09-06 18:31:32 -0400
commit11aef6e1074fa237ba8e3b765fe6abbbe42f437f (patch)
tree14f9798a37d8435021e5a066d71068be93234480 /js/compiler.ts
parent63c2fc8d1f60275590577b2a8de7a4431538ecc5 (diff)
Integrate format diagnostic host in DenoCompiler
Diffstat (limited to 'js/compiler.ts')
-rw-r--r--js/compiler.ts20
1 files changed, 8 insertions, 12 deletions
diff --git a/js/compiler.ts b/js/compiler.ts
index 3c2e3e4d1..21610014a 100644
--- a/js/compiler.ts
+++ b/js/compiler.ts
@@ -114,16 +114,6 @@ export class ModuleMetaData implements ts.IScriptSnapshot {
}
/**
- * The required minimal API to allow formatting of TypeScript compiler
- * diagnostics.
- */
-const formatDiagnosticsHost: ts.FormatDiagnosticsHost = {
- getCurrentDirectory: () => ".",
- getCanonicalFileName: (fileName: string) => fileName,
- getNewLine: () => EOL
-};
-
-/**
* Throw a module resolution error, when a module is unsuccessfully resolved.
*/
function throwResolutionError(
@@ -142,7 +132,8 @@ function throwResolutionError(
* with Deno specific APIs to provide an interface for compiling and running
* TypeScript and JavaScript modules.
*/
-export class DenoCompiler implements ts.LanguageServiceHost {
+export class DenoCompiler
+ implements ts.LanguageServiceHost, ts.FormatDiagnosticsHost {
// Modules are usually referenced by their ModuleSpecifier and ContainingFile,
// and keeping a map of the resolved module file name allows more efficient
// future resolution
@@ -370,7 +361,7 @@ export class DenoCompiler implements ts.LanguageServiceHost {
if (diagnostics.length > 0) {
const errMsg = this._ts.formatDiagnosticsWithColorAndContext(
diagnostics,
- formatDiagnosticsHost
+ this
);
console.log(errMsg);
// All TypeScript errors are terminal for deno
@@ -598,6 +589,11 @@ export class DenoCompiler implements ts.LanguageServiceHost {
// TypeScript Language Service API
+ getCanonicalFileName(fileName: string): string {
+ this._log("getCanonicalFileName", fileName);
+ return fileName;
+ }
+
getCompilationSettings(): ts.CompilerOptions {
this._log("getCompilationSettings()");
return this._options;