summaryrefslogtreecommitdiff
path: root/cli/js/compiler.ts
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2019-11-14 05:42:34 +1100
committerRy Dahl <ry@tinyclouds.org>2019-11-13 13:42:34 -0500
commit9837d324a7c3f5e1c850dadabfd670edad4aa85b (patch)
treea81de8e9e15f64edd2ccb6e30a351ca3b2305035 /cli/js/compiler.ts
parent279191ad9447c66fe1278589a7be242d035bb68b (diff)
Update to TypeScript 3.7 (#3275)
and update to prettier 1.19 Also, update `assert()` and remove not null assertions where possibly in `cli`. Closes #3273
Diffstat (limited to 'cli/js/compiler.ts')
-rw-r--r--cli/js/compiler.ts31
1 files changed, 14 insertions, 17 deletions
diff --git a/cli/js/compiler.ts b/cli/js/compiler.ts
index 179f2af6b..89c110740 100644
--- a/cli/js/compiler.ts
+++ b/cli/js/compiler.ts
@@ -67,7 +67,8 @@ type CompilerRequest = {
| {
type: CompilerRequestType.Bundle;
outFile?: string;
- });
+ }
+);
interface ConfigureResponse {
ignoredOptions?: string[];
@@ -186,11 +187,7 @@ class SourceFile {
throw new Error("SourceFile has already been processed.");
}
assert(this.sourceCode != null);
- const preProcessedFileInfo = ts.preProcessFile(
- this.sourceCode!,
- true,
- true
- );
+ const preProcessedFileInfo = ts.preProcessFile(this.sourceCode, true, true);
this.processed = true;
const files = (this.importedFiles = [] as Array<[string, string]>);
@@ -511,10 +508,10 @@ class Host implements ts.CompilerHost {
? this._getAsset(fileName)
: SourceFile.get(fileName);
assert(sourceFile != null);
- if (!sourceFile!.tsSourceFile) {
- sourceFile!.tsSourceFile = ts.createSourceFile(
+ if (!sourceFile.tsSourceFile) {
+ sourceFile.tsSourceFile = ts.createSourceFile(
fileName,
- sourceFile!.sourceCode,
+ sourceFile.sourceCode,
languageVersion
);
}
@@ -577,7 +574,7 @@ class Host implements ts.CompilerHost {
emitBundle(this._rootNames, this._outFile, data, sourceFiles!);
} else {
assert(sourceFiles.length == 1);
- const url = sourceFiles![0].fileName;
+ const url = sourceFiles[0].fileName;
const sourceFile = SourceFile.get(url);
if (sourceFile) {
@@ -635,9 +632,9 @@ window.compilerMain = function compilerMain(): void {
// This will recursively analyse all the code for other imports, requesting
// those from the privileged side, populating the in memory cache which
// will be used by the host, before resolving.
- const resolvedRootModules = (await processImports(
- rootNames.map(rootName => [rootName, rootName])
- )).map(info => info.url);
+ const resolvedRootModules = (
+ await processImports(rootNames.map(rootName => [rootName, rootName]))
+ ).map(info => info.url);
const host = new Host(
request.type,
@@ -669,8 +666,9 @@ window.compilerMain = function compilerMain(): void {
const options = host.getCompilationSettings();
const program = ts.createProgram(rootNames, options, host);
- diagnostics = ts.getPreEmitDiagnostics(program).filter(
- ({ code }): boolean => {
+ diagnostics = ts
+ .getPreEmitDiagnostics(program)
+ .filter(({ code }): boolean => {
// TS1103: 'for-await-of' statement is only allowed within an async
// function or async generator.
if (code === 1103) return false;
@@ -692,8 +690,7 @@ window.compilerMain = function compilerMain(): void {
// so we will ignore complaints about this compiler setting.
if (code === 5070) return false;
return true;
- }
- );
+ });
// We will only proceed with the emit if there are no diagnostics.
if (diagnostics && diagnostics.length === 0) {