mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Add isDeclarationFile and update similar all usage
This commit is contained in:
parent
6cb7ffb725
commit
3cb6c9cf45
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user