Add isDeclarationFile and update similar all usage

This commit is contained in:
Yui T 2014-10-09 14:19:36 -07:00
parent 6cb7ffb725
commit 3cb6c9cf45
2 changed files with 6 additions and 9 deletions

View File

@ -25,13 +25,6 @@ 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 (!isDeclarationFile(sourceFile)) {
if ((isExternalModule(sourceFile) || !compilerOptions.out) && !fileExtensionIs(sourceFile.filename, ".js")) {
@ -43,7 +36,7 @@ module ts {
}
export function isExternalModuleOrDeclarationFile(sourceFile: SourceFile) {
return isExternalModule(sourceFile) || (sourceFile.flags & NodeFlags.DeclarationFile) !== 0;
return isExternalModule(sourceFile) || isDeclarationFile(sourceFile);
}
// targetSourceFile is when users only want one file in entire project to be emitted. This is used in compilerOnSave feature

View File

@ -111,6 +111,10 @@ module ts {
return file.externalModuleIndicator !== undefined;
}
export function isDeclarationFile(file: SourceFile): boolean {
return (file.flags & NodeFlags.DeclarationFile) !== 0;
}
export function isPrologueDirective(node: Node): boolean {
return node.kind === SyntaxKind.ExpressionStatement && (<ExpressionStatement>node).expression.kind === SyntaxKind.StringLiteral;
}
@ -4125,7 +4129,7 @@ module ts {
}
}
}
else if (node.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || file.flags & NodeFlags.DeclarationFile)) {
else if (node.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) {
// TypeScript 1.0 spec (April 2014): 12.1.6
// An AmbientExternalModuleDeclaration declares an external module.
// This type of declaration is permitted only in the global module.