Add more test cases

This commit is contained in:
Yui T
2014-10-08 18:15:07 -07:00
parent 40f6b6719f
commit 67eff65e03
7 changed files with 75 additions and 10 deletions

View File

@@ -25,8 +25,15 @@ module ts {
return indentStrings[1].length;
}
function isDeclarationFile(sourceFile: SourceFile): boolean {
if (sourceFile.flags & NodeFlags.DeclarationFile) {
return true;
}
return false;
}
export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean {
if (!(sourceFile.flags & NodeFlags.DeclarationFile)) {
if (!isDeclarationFile(sourceFile)) {
if ((isExternalModule(sourceFile) || !compilerOptions.out) && !fileExtensionIs(sourceFile.filename, ".js")) {
return true;
}
@@ -3242,14 +3249,15 @@ module ts {
if (compilerOptions.out) {
emitFile(compilerOptions.out);
}
} else {
}
else {
// targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service)
if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) {
// If shouldEmitToOwnFile return true or targetSourceFile is an external module file, then emit targetSourceFile in its own output file
var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, ".js");
emitFile(jsFilePath, targetSourceFile);
}
else if (compilerOptions.out) {
else if (!isDeclarationFile(targetSourceFile) && compilerOptions.out) {
// Otherwise, if --out is specified and targetSourceFile shouldn't be emitted to own file, then emit all, non-external-module file, into one single output file
emitFile(compilerOptions.out);
}