diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 62d10dedfba9b..e0bc826f66ce5 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -43,7 +43,7 @@ namespace ts { if (sourceFile.kind === SyntaxKind.Bundle) { const jsFilePath = options.outFile || options.out!; const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - const declarationFilePath = (forceDtsPaths || options.declaration) ? removeFileExtension(jsFilePath) + Extension.Dts : undefined; + const declarationFilePath = (forceDtsPaths || getEmitDeclarations(options)) ? removeFileExtension(jsFilePath) + Extension.Dts : undefined; const declarationMapPath = getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; const bundleInfoPath = options.references && jsFilePath ? (removeFileExtension(jsFilePath) + infoExtension) : undefined; return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, bundleInfoPath }; @@ -53,7 +53,7 @@ namespace ts { const sourceMapFilePath = isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); // For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error const isJs = isSourceFileJavaScript(sourceFile); - const declarationFilePath = ((forceDtsPaths || options.declaration) && !isJs) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + const declarationFilePath = ((forceDtsPaths || getEmitDeclarations(options)) && !isJs) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; const declarationMapPath = getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, bundleInfoPath: undefined }; } @@ -192,7 +192,7 @@ namespace ts { // Setup and perform the transformation to retrieve declarations from the input files const nonJsFiles = filter(sourceFiles, isSourceFileNotJavaScript); const inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [createBundle(nonJsFiles, !isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; - if (emitOnlyDtsFiles && !compilerOptions.declaration) { + if (emitOnlyDtsFiles && !getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files nonJsFiles.forEach(collectLinkedAliases); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 75cdcaea32885..04814c4618a70 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2500,7 +2500,7 @@ namespace ts { } } - if (options.declarationMap && !options.declaration) { + if (options.declarationMap && !getEmitDeclarations(options)) { createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "declarationMap", "declaration"); } diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 751f5221167c4..695b9f8622f7d 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -304,7 +304,7 @@ namespace ts { const outputs: string[] = []; outputs.push(getOutputJavaScriptFileName(inputFileName, configFile)); - if (configFile.options.declaration && !fileExtensionIs(inputFileName, Extension.Json)) { + if (getEmitDeclarations(configFile.options) && !fileExtensionIs(inputFileName, Extension.Json)) { const dts = getOutputDeclarationFileName(inputFileName, configFile); outputs.push(dts); if (configFile.options.declarationMap) { @@ -320,7 +320,7 @@ namespace ts { } const outputs: string[] = []; outputs.push(project.options.outFile); - if (project.options.declaration) { + if (getEmitDeclarations(project.options)) { const dts = changeExtension(project.options.outFile, Extension.Dts); outputs.push(dts); if (project.options.declarationMap) { @@ -769,7 +769,10 @@ namespace ts { const program = createProgram(programOptions); // Don't emit anything in the presence of syntactic errors or options diagnostics - const syntaxDiagnostics = [...program.getOptionsDiagnostics(), ...program.getSyntacticDiagnostics()]; + const syntaxDiagnostics = [ + ...program.getOptionsDiagnostics(), + ...program.getConfigFileParsingDiagnostics(), + ...program.getSyntacticDiagnostics()]; if (syntaxDiagnostics.length) { resultFlags |= BuildResultFlags.SyntaxErrors; for (const diag of syntaxDiagnostics) { @@ -780,7 +783,7 @@ namespace ts { } // Don't emit .d.ts if there are decl file errors - if (program.getCompilerOptions().declaration) { + if (getEmitDeclarations(program.getCompilerOptions())) { const declDiagnostics = program.getDeclarationDiagnostics(); if (declDiagnostics.length) { resultFlags |= BuildResultFlags.DeclarationEmitErrors; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index e2be2746b77b2..e674e8d0d4d9b 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -6915,7 +6915,7 @@ namespace ts { } export function getAreDeclarationMapsEnabled(options: CompilerOptions) { - return !!(options.declaration && options.declarationMap); + return !!(getEmitDeclarations(options) && options.declarationMap); } export function getAllowSyntheticDefaultImports(compilerOptions: CompilerOptions) { diff --git a/tests/projects/outfile-concat/first/tsconfig.json b/tests/projects/outfile-concat/first/tsconfig.json index f71a818258537..8d63a0c4a0626 100644 --- a/tests/projects/outfile-concat/first/tsconfig.json +++ b/tests/projects/outfile-concat/first/tsconfig.json @@ -6,7 +6,6 @@ "strict": false, "sourceMap": true, "declarationMap": true, - "declaration": true, "outFile": "./bin/first-output.js" }, "files": [