Skip to content

Commit ba884bc

Browse files
author
Andy Hanson
committed
Merge branch 'master' into jsdoc
2 parents 8afe9fc + ada39c5 commit ba884bc

File tree

157 files changed

+4570
-1144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+4570
-1144
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
}
@@ -2545,7 +2545,7 @@ namespace ts {
25452545
}
25462546

25472547
function bindFunctionDeclaration(node: FunctionDeclaration) {
2548-
if (!isDeclarationFile(file) && !isInAmbientContext(node)) {
2548+
if (!file.isDeclarationFile && !isInAmbientContext(node)) {
25492549
if (isAsyncFunction(node)) {
25502550
emitFlags |= NodeFlags.HasAsyncFunctions;
25512551
}
@@ -2562,7 +2562,7 @@ namespace ts {
25622562
}
25632563

25642564
function bindFunctionExpression(node: FunctionExpression) {
2565-
if (!isDeclarationFile(file) && !isInAmbientContext(node)) {
2565+
if (!file.isDeclarationFile && !isInAmbientContext(node)) {
25662566
if (isAsyncFunction(node)) {
25672567
emitFlags |= NodeFlags.HasAsyncFunctions;
25682568
}
@@ -2576,7 +2576,7 @@ namespace ts {
25762576
}
25772577

25782578
function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
2579-
if (!isDeclarationFile(file) && !isInAmbientContext(node) && isAsyncFunction(node)) {
2579+
if (!file.isDeclarationFile && !isInAmbientContext(node) && isAsyncFunction(node)) {
25802580
emitFlags |= NodeFlags.HasAsyncFunctions;
25812581
}
25822582

src/compiler/checker.ts

Lines changed: 352 additions & 348 deletions
Large diffs are not rendered by default.

src/compiler/declarationEmitter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ namespace ts {
984984
const enumMemberValue = resolver.getConstantValue(node);
985985
if (enumMemberValue !== undefined) {
986986
write(" = ");
987-
write(enumMemberValue.toString());
987+
write(getTextOfConstantValue(enumMemberValue));
988988
}
989989
write(",");
990990
writeLine();
@@ -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/diagnosticMessages.json

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@
10671067
"category": "Error",
10681068
"code": 2345
10691069
},
1070-
"Supplied parameters do not match any signature of call target.": {
1070+
"Call target does not contain any signatures.": {
10711071
"category": "Error",
10721072
"code": 2346
10731073
},
@@ -1855,6 +1855,30 @@
18551855
"category": "Error",
18561856
"code": 2552
18571857
},
1858+
"Computed values are not permitted in an enum with string valued members.": {
1859+
"category": "Error",
1860+
"code": 2553
1861+
},
1862+
"Expected {0} arguments, but got {1}.": {
1863+
"category": "Error",
1864+
"code": 2554
1865+
},
1866+
"Expected at least {0} arguments, but got {1}.": {
1867+
"category": "Error",
1868+
"code": 2555
1869+
},
1870+
"Expected {0} arguments, but got a minimum of {1}.": {
1871+
"category": "Error",
1872+
"code": 2556
1873+
},
1874+
"Expected at least {0} arguments, but got a minimum of {1}.": {
1875+
"category": "Error",
1876+
"code": 2557
1877+
},
1878+
"Expected {0} type arguments, but got {1}.": {
1879+
"category": "Error",
1880+
"code": 2558
1881+
},
18581882
"JSX element attributes type '{0}' may not be a union type.": {
18591883
"category": "Error",
18601884
"code": 2600

src/compiler/emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ namespace ts {
11541154
// check if constant enum value is integer
11551155
const constantValue = getConstantValue(expression);
11561156
// isFinite handles cases when constantValue is undefined
1157-
return isFinite(constantValue)
1157+
return typeof constantValue === "number" && isFinite(constantValue)
11581158
&& Math.floor(constantValue) === constantValue
11591159
&& printerOptions.removeComments;
11601160
}

src/compiler/factory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,7 @@ namespace ts {
23712371
/**
23722372
* Sets the constant value to emit for an expression.
23732373
*/
2374-
export function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number) {
2374+
export function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number) {
23752375
const emitNode = getOrCreateEmitNode(node);
23762376
emitNode.constantValue = value;
23772377
return node;
@@ -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

src/compiler/transformers/jsx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace ts {
1515
* @param node A SourceFile node.
1616
*/
1717
function transformSourceFile(node: SourceFile) {
18-
if (isDeclarationFile(node)) {
18+
if (node.isDeclarationFile) {
1919
return node;
2020
}
2121

src/compiler/transformers/module/es2015.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace ts {
1616
return transformSourceFile;
1717

1818
function transformSourceFile(node: SourceFile) {
19-
if (isDeclarationFile(node)) {
19+
if (node.isDeclarationFile) {
2020
return node;
2121
}
2222

src/compiler/transformers/module/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ namespace ts {
5555
* @param node The SourceFile node.
5656
*/
5757
function transformSourceFile(node: SourceFile) {
58-
if (isDeclarationFile(node) || !(isExternalModule(node) || compilerOptions.isolatedModules)) {
58+
if (node.isDeclarationFile || !(isExternalModule(node) || compilerOptions.isolatedModules)) {
5959
return node;
6060
}
6161

src/compiler/transformers/module/system.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ namespace ts {
5050
* @param node The SourceFile node.
5151
*/
5252
function transformSourceFile(node: SourceFile) {
53-
if (isDeclarationFile(node)
54-
|| !(isExternalModule(node)
55-
|| compilerOptions.isolatedModules)) {
53+
if (node.isDeclarationFile || !(isExternalModule(node) || compilerOptions.isolatedModules)) {
5654
return node;
5755
}
5856

src/compiler/transformers/ts.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace ts {
7676
* @param node A SourceFile node.
7777
*/
7878
function transformSourceFile(node: SourceFile) {
79-
if (isDeclarationFile(node)) {
79+
if (node.isDeclarationFile) {
8080
return node;
8181
}
8282

@@ -2494,22 +2494,27 @@ namespace ts {
24942494
// we pass false as 'generateNameForComputedPropertyName' for a backward compatibility purposes
24952495
// old emitter always generate 'expression' part of the name as-is.
24962496
const name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false);
2497+
const valueExpression = transformEnumMemberDeclarationValue(member);
2498+
const innerAssignment = createAssignment(
2499+
createElementAccess(
2500+
currentNamespaceContainerName,
2501+
name
2502+
),
2503+
valueExpression
2504+
);
2505+
const outerAssignment = valueExpression.kind === SyntaxKind.StringLiteral ?
2506+
innerAssignment :
2507+
createAssignment(
2508+
createElementAccess(
2509+
currentNamespaceContainerName,
2510+
innerAssignment
2511+
),
2512+
name
2513+
);
24972514
return setTextRange(
24982515
createStatement(
24992516
setTextRange(
2500-
createAssignment(
2501-
createElementAccess(
2502-
currentNamespaceContainerName,
2503-
createAssignment(
2504-
createElementAccess(
2505-
currentNamespaceContainerName,
2506-
name
2507-
),
2508-
transformEnumMemberDeclarationValue(member)
2509-
)
2510-
),
2511-
name
2512-
),
2517+
outerAssignment,
25132518
member
25142519
)
25152520
),
@@ -3349,7 +3354,7 @@ namespace ts {
33493354
return node;
33503355
}
33513356

3352-
function tryGetConstEnumValue(node: Node): number {
3357+
function tryGetConstEnumValue(node: Node): string | number {
33533358
if (compilerOptions.isolatedModules) {
33543359
return undefined;
33553360
}

0 commit comments

Comments
 (0)