Address PR feedback: expand ternary return into if block, add check to ensure proper options usage

This commit is contained in:
Asad Saeeduddin
2016-02-20 17:40:39 -05:00
parent ba63a48fe1
commit c8aedbf382
2 changed files with 10 additions and 4 deletions

View File

@@ -1670,6 +1670,10 @@ namespace ts {
}
}
if (!options.declaration && options.declarationDir) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "declarationDir", "declaration"));
}
const languageVersion = options.target || ScriptTarget.ES3;
const outFile = options.outFile || options.out;

View File

@@ -2015,11 +2015,13 @@ namespace ts {
export function getDeclarationEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost) {
const options = host.getCompilerOptions();
const outputDir = options.declarationDir || options.outDir; // Prefer declaration folder if specified
return options.declaration ? removeFileExtension(
outputDir
if (options.declaration) {
const path = outputDir
? getSourceFilePathInNewDir(sourceFile, host, outputDir)
: sourceFile.fileName
) + ".d.ts" : undefined;
: sourceFile.fileName;
return removeFileExtension(path) + ".d.ts";
}
}
export function getEmitScriptTarget(compilerOptions: CompilerOptions) {