Skip to content

Commit 2c3c321

Browse files
committed
Merge branch 'master' into tscJsFiles
2 parents 2d083f7 + bff9148 commit 2c3c321

513 files changed

Lines changed: 3985 additions & 2886 deletions

File tree

Some content is hidden

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

src/compiler/checker.ts

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,7 +2209,7 @@ namespace ts {
22092209

22102210
/**
22112211
* Push an entry on the type resolution stack. If an entry with the given target and the given property name
2212-
* is already on the stack, and no entries in between already have a type, then a circularity has occurred.
2212+
* is already on the stack, and no entries in between already have a type, then a circularity has occurred.
22132213
* In this case, the result values of the existing entry and all entries pushed after it are changed to false,
22142214
* and the value false is returned. Otherwise, the new entry is just pushed onto the stack, and true is returned.
22152215
* In order to see if the same query has already been done before, the target object and the propertyName both
@@ -5243,7 +5243,7 @@ namespace ts {
52435243
// Only want to compare the construct signatures for abstractness guarantees.
52445244

52455245
// Because the "abstractness" of a class is the same across all construct signatures
5246-
// (internally we are checking the corresponding declaration), it is enough to perform
5246+
// (internally we are checking the corresponding declaration), it is enough to perform
52475247
// the check and report an error once over all pairs of source and target construct signatures.
52485248
//
52495249
// sourceSig and targetSig are (possibly) undefined.
@@ -6642,7 +6642,7 @@ namespace ts {
66426642
let needToCaptureLexicalThis = false;
66436643

66446644
if (!isCallExpression) {
6645-
// adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting
6645+
// adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting
66466646
while (container && container.kind === SyntaxKind.ArrowFunction) {
66476647
container = getSuperContainer(container, /*includeFunctions*/ true);
66486648
needToCaptureLexicalThis = languageVersion < ScriptTarget.ES6;
@@ -6652,7 +6652,7 @@ namespace ts {
66526652
let canUseSuperExpression = isLegalUsageOfSuperExpression(container);
66536653
let nodeCheckFlag: NodeCheckFlags = 0;
66546654

6655-
// always set NodeCheckFlags for 'super' expression node
6655+
// always set NodeCheckFlags for 'super' expression node
66566656
if (canUseSuperExpression) {
66576657
if ((container.flags & NodeFlags.Static) || isCallExpression) {
66586658
nodeCheckFlag = NodeCheckFlags.SuperStatic;
@@ -8568,7 +8568,7 @@ namespace ts {
85688568
// A method or accessor declaration decorator will have two or three arguments (see
85698569
// `PropertyDecorator` and `MethodDecorator` in core.d.ts)
85708570

8571-
// If we are emitting decorators for ES3, we will only pass two arguments.
8571+
// If we are emitting decorators for ES3, we will only pass two arguments.
85728572
if (languageVersion === ScriptTarget.ES3) {
85738573
return 2;
85748574
}
@@ -11306,7 +11306,8 @@ namespace ts {
1130611306
}
1130711307

1130811308
function checkNonThenableType(type: Type, location?: Node, message?: DiagnosticMessage) {
11309-
if (!(type.flags & TypeFlags.Any) && isTypeAssignableTo(type, getGlobalThenableType())) {
11309+
type = getWidenedType(type);
11310+
if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) {
1131011311
if (location) {
1131111312
if (!message) {
1131211313
message = Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member;
@@ -12544,7 +12545,12 @@ namespace ts {
1254412545
if (isAsyncFunctionLike(func)) {
1254512546
let promisedType = getPromisedType(returnType);
1254612547
let awaitedType = checkAwaitedType(exprType, node.expression, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member);
12547-
checkTypeAssignableTo(awaitedType, promisedType, node.expression);
12548+
if (promisedType) {
12549+
// If the function has a return type, but promisedType is
12550+
// undefined, an error will be reported in checkAsyncFunctionReturnType
12551+
// so we don't need to report one here.
12552+
checkTypeAssignableTo(awaitedType, promisedType, node.expression);
12553+
}
1254812554
}
1254912555
else {
1255012556
checkTypeAssignableTo(exprType, returnType, node.expression);
@@ -13154,13 +13160,13 @@ namespace ts {
1315413160
autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient);
1315513161
}
1315613162
else if (ambient && !enumIsConst) {
13157-
// In ambient enum declarations that specify no const modifier, enum member declarations
13163+
// In ambient enum declarations that specify no const modifier, enum member declarations
1315813164
// that omit a value are considered computed members (as opposed to having auto-incremented values assigned).
1315913165
autoValue = undefined;
1316013166
}
1316113167
else if (previousEnumMemberIsNonConstant) {
13162-
// If the member declaration specifies no value, the member is considered a constant enum member.
13163-
// If the member is the first member in the enum declaration, it is assigned the value zero.
13168+
// If the member declaration specifies no value, the member is considered a constant enum member.
13169+
// If the member is the first member in the enum declaration, it is assigned the value zero.
1316413170
// Otherwise, it is assigned the value of the immediately preceding member plus one,
1316513171
// and an error occurs if the immediately preceding member is not a constant enum member
1316613172
error(member.name, Diagnostics.Enum_member_must_have_initializer);
@@ -14100,7 +14106,7 @@ namespace ts {
1410014106
case SyntaxKind.ClassDeclaration:
1410114107
case SyntaxKind.InterfaceDeclaration:
1410214108
// If we didn't come from static member of class or interface,
14103-
// add the type parameters into the symbol table
14109+
// add the type parameters into the symbol table
1410414110
// (type parameters of classDeclaration/classExpression and interface are in member property of the symbol.
1410514111
// Note: that the memberFlags come from previous iteration.
1410614112
if (!(memberFlags & NodeFlags.Static)) {
@@ -14764,31 +14770,6 @@ namespace ts {
1476414770
return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
1476514771
}
1476614772

14767-
function getBlockScopedVariableId(n: Identifier): number {
14768-
Debug.assert(!nodeIsSynthesized(n));
14769-
14770-
let isVariableDeclarationOrBindingElement =
14771-
n.parent.kind === SyntaxKind.BindingElement || (n.parent.kind === SyntaxKind.VariableDeclaration && (<VariableDeclaration>n.parent).name === n);
14772-
14773-
let symbol =
14774-
(isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) ||
14775-
getNodeLinks(n).resolvedSymbol ||
14776-
resolveName(n, n.text, SymbolFlags.Value | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined);
14777-
14778-
let isLetOrConst =
14779-
symbol &&
14780-
(symbol.flags & SymbolFlags.BlockScopedVariable) &&
14781-
symbol.valueDeclaration.parent.kind !== SyntaxKind.CatchClause;
14782-
14783-
if (isLetOrConst) {
14784-
// side-effect of calling this method:
14785-
// assign id to symbol if it was not yet set
14786-
getSymbolLinks(symbol);
14787-
return symbol.id;
14788-
}
14789-
return undefined;
14790-
}
14791-
1479214773
function instantiateSingleCallFunctionType(functionType: Type, typeArguments: Type[]): Type {
1479314774
if (functionType === unknownType) {
1479414775
return unknownType;
@@ -14823,7 +14804,6 @@ namespace ts {
1482314804
isEntityNameVisible,
1482414805
getConstantValue,
1482514806
collectLinkedAliases,
14826-
getBlockScopedVariableId,
1482714807
getReferencedValueDeclaration,
1482814808
getTypeReferenceSerializationKind,
1482914809
isOptionalParameter

src/compiler/commandLineParser.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,13 @@ namespace ts {
529529
let opt = optionNameMap[id];
530530
let { hasValidValue, value } = parseJsonCompilerOption(opt, jsonOptions[id], errors);
531531
if (hasValidValue) {
532-
options[opt.name] = opt.isFilePath ? normalizePath(combinePaths(basePath, <string>value)) : value;
532+
if (opt.isFilePath) {
533+
value = normalizePath(combinePaths(basePath, <string>value));
534+
if (value === "") {
535+
value = ".";
536+
}
537+
}
538+
options[opt.name] = value;
533539
}
534540
}
535541
else {
@@ -594,4 +600,4 @@ namespace ts {
594600
return fileNames;
595601
}
596602
}
597-
}
603+
}

src/compiler/emitter.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3787,7 +3787,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
37873787
write(";");
37883788
}
37893789
}
3790-
if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile) {
3790+
if (modulekind !== ModuleKind.ES6 && node.parent === currentSourceFile) {
37913791
forEach(node.declarationList.declarations, emitExportVariableAssignments);
37923792
}
37933793
}
@@ -4013,7 +4013,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
40134013
}
40144014

40154015
emitSignatureAndBody(node);
4016-
if (languageVersion < ScriptTarget.ES6 && node.kind === SyntaxKind.FunctionDeclaration && node.parent === currentSourceFile && node.name) {
4016+
if (modulekind !== ModuleKind.ES6 && node.kind === SyntaxKind.FunctionDeclaration && node.parent === currentSourceFile && node.name) {
40174017
emitExportMemberAssignments((<FunctionDeclaration>node).name);
40184018
}
40194019

@@ -4689,6 +4689,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
46894689
else {
46904690
emitClassLikeDeclarationForES6AndHigher(node);
46914691
}
4692+
if (modulekind !== ModuleKind.ES6 && node.parent === currentSourceFile && node.name) {
4693+
emitExportMemberAssignments(node.name);
4694+
}
46924695
}
46934696

46944697
function emitClassLikeDeclarationForES6AndHigher(node: ClassLikeDeclaration) {
@@ -4787,8 +4790,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
47874790

47884791
// emit name if
47894792
// - node has a name
4790-
// - this is default export and target is not ES6 (for ES6 `export default` does not need to be compiled downlevel)
4791-
if ((node.name || (node.flags & NodeFlags.Default && languageVersion < ScriptTarget.ES6)) && !thisNodeIsDecorated) {
4793+
// - this is default export with static initializers
4794+
if ((node.name || (node.flags & NodeFlags.Default && staticProperties.length > 0)) && !thisNodeIsDecorated) {
47924795
write(" ");
47934796
emitDeclarationName(node);
47944797
}
@@ -4936,10 +4939,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
49364939
if (node.kind === SyntaxKind.ClassDeclaration) {
49374940
emitExportMemberAssignment(<ClassDeclaration>node);
49384941
}
4939-
4940-
if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile && node.name) {
4941-
emitExportMemberAssignments(node.name);
4942-
}
49434942
}
49444943

49454944
function emitClassMemberPrefix(node: ClassLikeDeclaration, member: Node) {
@@ -5511,7 +5510,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
55115510
emitEnd(node);
55125511
write(";");
55135512
}
5514-
if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile) {
5513+
if (modulekind !== ModuleKind.ES6 && node.parent === currentSourceFile) {
55155514
if (modulekind === ModuleKind.System && (node.flags & NodeFlags.Export)) {
55165515
// write the call to exporter for enum
55175516
writeLine();
@@ -5647,8 +5646,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
56475646
}
56485647

56495648
/*
5650-
* Some bundlers (SystemJS builder) sometimes want to rename dependencies.
5651-
* Here we check if alternative name was provided for a given moduleName and return it if possible.
5649+
* Some bundlers (SystemJS builder) sometimes want to rename dependencies.
5650+
* Here we check if alternative name was provided for a given moduleName and return it if possible.
56525651
*/
56535652
function tryRenameExternalModule(moduleName: LiteralExpression): string {
56545653
if (currentSourceFile.renamedDependencies && hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) {
@@ -7076,7 +7075,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
70767075
return shouldEmitEnumDeclaration(<EnumDeclaration>node);
70777076
}
70787077

7079-
// If the node is emitted in specialized fashion, dont emit comments as this node will handle
7078+
// If the node is emitted in specialized fashion, dont emit comments as this node will handle
70807079
// emitting comments when emitting itself
70817080
Debug.assert(!isSpecializedCommentHandling(node));
70827081

src/compiler/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,6 @@ namespace ts {
15981598
isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult;
15991599
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
16001600
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
1601-
getBlockScopedVariableId(node: Identifier): number;
16021601
getReferencedValueDeclaration(reference: Identifier): Declaration;
16031602
getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind;
16041603
isOptionalParameter(node: ParameterDeclaration): boolean;

src/harness/typeWriter.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ class TypeWriterWalker {
5757
symbolString += ", ";
5858
let declSourceFile = declaration.getSourceFile();
5959
let declLineAndCharacter = declSourceFile.getLineAndCharacterOfPosition(declaration.pos);
60-
symbolString += `Decl(${ ts.getBaseFileName(declSourceFile.fileName) }, ${ declLineAndCharacter.line }, ${ declLineAndCharacter.character })`;
60+
let fileName = ts.getBaseFileName(declSourceFile.fileName);
61+
let isLibFile = /lib(.*)\.d\.ts/i.test(fileName);
62+
symbolString += `Decl(${ fileName }, ${ isLibFile ? "--" : declLineAndCharacter.line }, ${ isLibFile ? "--" : declLineAndCharacter.character })`;
6163
}
6264
}
6365
symbolString += ")";

0 commit comments

Comments
 (0)