Skip to content

Commit 0ff187c

Browse files
author
Andy Hanson
committed
Remove 'isDeclarationFile()' function, use '.isDeclarationFile'
1 parent fc4dd2b commit 0ff187c

File tree

17 files changed

+27
-35
lines changed

17 files changed

+27
-35
lines changed

src/compiler/binder.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ namespace ts {
149149
inStrictMode = bindInStrictMode(file, opts);
150150
classifiableNames = createMap<string>();
151151
symbolCount = 0;
152-
skipTransformFlagAggregation = isDeclarationFile(file);
152+
skipTransformFlagAggregation = file.isDeclarationFile;
153153

154154
Symbol = objectAllocator.getSymbolConstructor();
155155

@@ -182,7 +182,7 @@ namespace ts {
182182
return bindSourceFile;
183183

184184
function bindInStrictMode(file: SourceFile, opts: CompilerOptions): boolean {
185-
if ((opts.alwaysStrict === undefined ? opts.strict : opts.alwaysStrict) && !isDeclarationFile(file)) {
185+
if ((opts.alwaysStrict === undefined ? opts.strict : opts.alwaysStrict) && !file.isDeclarationFile) {
186186
// bind in strict mode source files with alwaysStrict option
187187
return true;
188188
}
@@ -2527,7 +2527,7 @@ namespace ts {
25272527
}
25282528

25292529
function bindFunctionDeclaration(node: FunctionDeclaration) {
2530-
if (!isDeclarationFile(file) && !isInAmbientContext(node)) {
2530+
if (!file.isDeclarationFile && !isInAmbientContext(node)) {
25312531
if (isAsyncFunction(node)) {
25322532
emitFlags |= NodeFlags.HasAsyncFunctions;
25332533
}
@@ -2544,7 +2544,7 @@ namespace ts {
25442544
}
25452545

25462546
function bindFunctionExpression(node: FunctionExpression) {
2547-
if (!isDeclarationFile(file) && !isInAmbientContext(node)) {
2547+
if (!file.isDeclarationFile && !isInAmbientContext(node)) {
25482548
if (isAsyncFunction(node)) {
25492549
emitFlags |= NodeFlags.HasAsyncFunctions;
25502550
}
@@ -2558,7 +2558,7 @@ namespace ts {
25582558
}
25592559

25602560
function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
2561-
if (!isDeclarationFile(file) && !isInAmbientContext(node)) {
2561+
if (!file.isDeclarationFile && !isInAmbientContext(node)) {
25622562
if (isAsyncFunction(node)) {
25632563
emitFlags |= NodeFlags.HasAsyncFunctions;
25642564
}

src/compiler/declarationEmitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1840,7 +1840,7 @@ namespace ts {
18401840
function writeReferencePath(referencedFile: SourceFile, addBundledFileReference: boolean, emitOnlyDtsFiles: boolean): boolean {
18411841
let declFileName: string;
18421842
let addedBundledEmitReference = false;
1843-
if (isDeclarationFile(referencedFile)) {
1843+
if (referencedFile.isDeclarationFile) {
18441844
// Declaration file, use declaration file name
18451845
declFileName = referencedFile.fileName;
18461846
}

src/compiler/factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3858,7 +3858,7 @@ namespace ts {
38583858
if (file.moduleName) {
38593859
return createLiteral(file.moduleName);
38603860
}
3861-
if (!isDeclarationFile(file) && (options.out || options.outFile)) {
3861+
if (!file.isDeclarationFile && (options.out || options.outFile)) {
38623862
return createLiteral(getExternalModuleNameFromPath(host, file.fileName));
38633863
}
38643864
return undefined;

src/compiler/program.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ namespace ts {
13091309
}
13101310

13111311
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
1312-
return isDeclarationFile(sourceFile) ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
1312+
return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
13131313
}
13141314

13151315
function getOptionsDiagnostics(): Diagnostic[] {
@@ -1348,7 +1348,6 @@ namespace ts {
13481348

13491349
const isJavaScriptFile = isSourceFileJavaScript(file);
13501350
const isExternalModuleFile = isExternalModule(file);
1351-
const isDtsFile = isDeclarationFile(file);
13521351

13531352
let imports: LiteralExpression[];
13541353
let moduleAugmentations: LiteralExpression[];
@@ -1401,7 +1400,7 @@ namespace ts {
14011400
}
14021401
break;
14031402
case SyntaxKind.ModuleDeclaration:
1404-
if (isAmbientModule(<ModuleDeclaration>node) && (inAmbientModule || hasModifier(node, ModifierFlags.Ambient) || isDeclarationFile(file))) {
1403+
if (isAmbientModule(<ModuleDeclaration>node) && (inAmbientModule || hasModifier(node, ModifierFlags.Ambient) || file.isDeclarationFile)) {
14051404
const moduleName = <LiteralExpression>(<ModuleDeclaration>node).name;
14061405
// Ambient module declarations can be interpreted as augmentations for some existing external modules.
14071406
// This will happen in two cases:
@@ -1412,7 +1411,7 @@ namespace ts {
14121411
(moduleAugmentations || (moduleAugmentations = [])).push(moduleName);
14131412
}
14141413
else if (!inAmbientModule) {
1415-
if (isDtsFile) {
1414+
if (file.isDeclarationFile) {
14161415
// for global .d.ts files record name of ambient module
14171416
(ambientModules || (ambientModules = [])).push(moduleName.text);
14181417
}
@@ -1730,7 +1729,7 @@ namespace ts {
17301729
const absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory));
17311730

17321731
for (const sourceFile of sourceFiles) {
1733-
if (!isDeclarationFile(sourceFile)) {
1732+
if (!sourceFile.isDeclarationFile) {
17341733
const absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
17351734
if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
17361735
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
@@ -1843,13 +1842,13 @@ namespace ts {
18431842
const languageVersion = options.target || ScriptTarget.ES3;
18441843
const outFile = options.outFile || options.out;
18451844

1846-
const firstNonAmbientExternalModuleSourceFile = forEach(files, f => isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
1845+
const firstNonAmbientExternalModuleSourceFile = forEach(files, f => isExternalModule(f) && !f.isDeclarationFile ? f : undefined);
18471846
if (options.isolatedModules) {
18481847
if (options.module === ModuleKind.None && languageVersion < ScriptTarget.ES2015) {
18491848
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher));
18501849
}
18511850

1852-
const firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
1851+
const firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !f.isDeclarationFile ? f : undefined);
18531852
if (firstNonExternalModuleSourceFile) {
18541853
const span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
18551854
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));

src/compiler/transformer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ namespace ts {
165165
};
166166

167167
function transformRoot(node: T) {
168-
return node && (!isSourceFile(node) || !isDeclarationFile(node)) ? transformation(node) : node;
168+
return node && (!isSourceFile(node) || !node.isDeclarationFile) ? transformation(node) : node;
169169
}
170170

171171
/**

src/compiler/transformers/es2015.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ namespace ts {
295295
return transformSourceFile;
296296

297297
function transformSourceFile(node: SourceFile) {
298-
if (isDeclarationFile(node)) {
298+
if (node.isDeclarationFile) {
299299
return node;
300300
}
301301

src/compiler/transformers/es2016.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace ts {
99
return transformSourceFile;
1010

1111
function transformSourceFile(node: SourceFile) {
12-
if (isDeclarationFile(node)) {
12+
if (node.isDeclarationFile) {
1313
return node;
1414
}
1515

src/compiler/transformers/es2017.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace ts {
4747
return transformSourceFile;
4848

4949
function transformSourceFile(node: SourceFile) {
50-
if (isDeclarationFile(node)) {
50+
if (node.isDeclarationFile) {
5151
return node;
5252
}
5353

src/compiler/transformers/esnext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace ts {
3333
return transformSourceFile;
3434

3535
function transformSourceFile(node: SourceFile) {
36-
if (isDeclarationFile(node)) {
36+
if (node.isDeclarationFile) {
3737
return node;
3838
}
3939

src/compiler/transformers/generators.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,7 @@ namespace ts {
293293
return transformSourceFile;
294294

295295
function transformSourceFile(node: SourceFile) {
296-
if (isDeclarationFile(node)
297-
|| (node.transformFlags & TransformFlags.ContainsGenerator) === 0) {
296+
if (node.isDeclarationFile || (node.transformFlags & TransformFlags.ContainsGenerator) === 0) {
298297
return node;
299298
}
300299

0 commit comments

Comments
 (0)