From c4df3da5a3b80d590b6f3743ad28dbbd5d1d4e4c Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Wed, 21 Nov 2018 09:59:37 -0800 Subject: [PATCH 1/2] Update user baselines (#28633) --- tests/baselines/reference/user/bluebird.log | 1 - tests/baselines/reference/user/follow-redirects.log | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/baselines/reference/user/bluebird.log b/tests/baselines/reference/user/bluebird.log index 25f9e8ab6ab..aea76fa7f2c 100644 --- a/tests/baselines/reference/user/bluebird.log +++ b/tests/baselines/reference/user/bluebird.log @@ -162,7 +162,6 @@ node_modules/bluebird/js/release/some.js(133,23): error TS2339: Property 'promis node_modules/bluebird/js/release/using.js(78,20): error TS2339: Property 'doDispose' does not exist on type 'Disposer'. node_modules/bluebird/js/release/using.js(97,23): error TS2339: Property 'data' does not exist on type 'FunctionDisposer'. node_modules/bluebird/js/release/using.js(223,15): error TS2350: Only a void function can be called with the 'new' keyword. -node_modules/bluebird/js/release/util.js(251,28): error TS2554: Expected 0 arguments, but got 2. node_modules/bluebird/js/release/util.js(279,45): error TS2345: Argument of type 'PropertyDescriptor | { value: any; } | undefined' is not assignable to parameter of type 'PropertyDescriptor & ThisType'. Type 'undefined' is not assignable to type 'PropertyDescriptor & ThisType'. Type 'undefined' is not assignable to type 'PropertyDescriptor'. diff --git a/tests/baselines/reference/user/follow-redirects.log b/tests/baselines/reference/user/follow-redirects.log index 4b5959dd0e3..565dd1e208e 100644 --- a/tests/baselines/reference/user/follow-redirects.log +++ b/tests/baselines/reference/user/follow-redirects.log @@ -1,12 +1,12 @@ Exit Code: 1 Standard output: -node_modules/follow-redirects/index.js(86,10): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. -node_modules/follow-redirects/index.js(87,10): error TS2339: Property 'abort' does not exist on type 'RedirectableRequest'. -node_modules/follow-redirects/index.js(145,10): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. -node_modules/follow-redirects/index.js(211,12): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. -node_modules/follow-redirects/index.js(245,35): error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'. +node_modules/follow-redirects/index.js(97,10): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. +node_modules/follow-redirects/index.js(98,10): error TS2339: Property 'abort' does not exist on type 'RedirectableRequest'. +node_modules/follow-redirects/index.js(156,10): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. +node_modules/follow-redirects/index.js(222,12): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. +node_modules/follow-redirects/index.js(256,35): error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'. Type 'undefined' is not assignable to type 'string'. -node_modules/follow-redirects/index.js(258,10): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. +node_modules/follow-redirects/index.js(269,10): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. From 2128cc49a07ba42c217d6541ff66ae8ed3c85ba5 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 21 Nov 2018 10:45:08 -0800 Subject: [PATCH 2/2] Dont explicitly get declaration diagnostics --- src/compiler/tsbuild.ts | 36 +++++++++++++++++++----------------- src/compiler/utilities.ts | 2 +- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index e17057b9140..1bf5bed76a2 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -1050,14 +1050,6 @@ namespace ts { return buildErrors(syntaxDiagnostics, BuildResultFlags.SyntaxErrors, "Syntactic"); } - // Don't emit .d.ts if there are decl file errors - if (getEmitDeclarations(program.getCompilerOptions())) { - const declDiagnostics = program.getDeclarationDiagnostics(); - if (declDiagnostics.length) { - return buildErrors(declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"); - } - } - // Same as above but now for semantic diagnostics const semanticDiagnostics = program.getSemanticDiagnostics(); if (semanticDiagnostics.length) { @@ -1066,14 +1058,23 @@ namespace ts { let newestDeclarationFileContentChangedTime = minimumDate; let anyDtsChanged = false; - let emitDiagnostics: Diagnostic[] | undefined; - const reportEmitDiagnostic = (d: Diagnostic) => (emitDiagnostics || (emitDiagnostics = [])).push(d); - emitFilesAndReportErrors(program, reportEmitDiagnostic, writeFileName, /*reportSummary*/ undefined, (fileName, content, writeBom, onError) => { + let declDiagnostics: Diagnostic[] | undefined; + const reportDeclarationDiagnostics = (d: Diagnostic) => (declDiagnostics || (declDiagnostics = [])).push(d); + const outputFiles: OutputFile[] = []; + emitFilesAndReportErrors(program, reportDeclarationDiagnostics, writeFileName, /*reportSummary*/ undefined, (name, text, writeByteOrderMark) => outputFiles.push({ name, text, writeByteOrderMark })); + // Don't emit .d.ts if there are decl file errors + if (declDiagnostics) { + return buildErrors(declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"); + } + + // Actual Emit + const emitterDiagnostics = createDiagnosticCollection(); + outputFiles.forEach(({ name, text, writeByteOrderMark }) => { let priorChangeTime: Date | undefined; - if (!anyDtsChanged && isDeclarationFile(fileName)) { + if (!anyDtsChanged && isDeclarationFile(name)) { // Check for unchanged .d.ts files - if (host.fileExists(fileName) && host.readFile(fileName) === content) { - priorChangeTime = host.getModifiedTime(fileName); + if (host.fileExists(name) && host.readFile(name) === text) { + priorChangeTime = host.getModifiedTime(name); } else { resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; @@ -1081,14 +1082,15 @@ namespace ts { } } - host.writeFile(fileName, content, writeBom, onError, emptyArray); + writeFile(host, emitterDiagnostics, name, text, writeByteOrderMark); if (priorChangeTime !== undefined) { newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime); - unchangedOutputs.setValue(fileName, priorChangeTime); + unchangedOutputs.setValue(name, priorChangeTime); } }); - if (emitDiagnostics) { + const emitDiagnostics = emitterDiagnostics.getDiagnostics(); + if (emitDiagnostics.length) { return buildErrors(emitDiagnostics, BuildResultFlags.EmitErrors, "Emit"); } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 8ed85db3a23..30fd1ca1784 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3402,7 +3402,7 @@ namespace ts { return combinePaths(newDirPath, sourceFilePath); } - export function writeFile(host: EmitHost, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean, sourceFiles?: ReadonlyArray) { + export function writeFile(host: { writeFile: WriteFileCallback; }, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean, sourceFiles?: ReadonlyArray) { host.writeFile(fileName, data, writeByteOrderMark, hostErrorMessage => { diagnostics.add(createCompilerDiagnostic(Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); }, sourceFiles);