@@ -256,6 +256,7 @@ namespace ts {
256
256
return resolveName(location, escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
257
257
},
258
258
getJsxNamespace: () => unescapeLeadingUnderscores(getJsxNamespace()),
259
+ getAccessibleSymbolChain,
259
260
};
260
261
261
262
const tupleTypes: GenericType[] = [];
@@ -763,10 +764,6 @@ namespace ts {
763
764
return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 });
764
765
}
765
766
766
- function getObjectFlags(type: Type): ObjectFlags {
767
- return type.flags & TypeFlags.Object ? (<ObjectType>type).objectFlags : 0;
768
- }
769
-
770
767
function isGlobalSourceFile(node: Node) {
771
768
return node.kind === SyntaxKind.SourceFile && !isExternalOrCommonJsModule(<SourceFile>node);
772
769
}
@@ -10452,20 +10449,6 @@ namespace ts {
10452
10449
!hasBaseType(checkClass, getDeclaringClass(p)) : false) ? undefined : checkClass;
10453
10450
}
10454
10451
10455
- // Return true if the given type is the constructor type for an abstract class
10456
- function isAbstractConstructorType(type: Type) {
10457
- if (getObjectFlags(type) & ObjectFlags.Anonymous) {
10458
- const symbol = type.symbol;
10459
- if (symbol && symbol.flags & SymbolFlags.Class) {
10460
- const declaration = getClassLikeDeclarationOfSymbol(symbol);
10461
- if (declaration && hasModifier(declaration, ModifierFlags.Abstract)) {
10462
- return true;
10463
- }
10464
- }
10465
- }
10466
- return false;
10467
- }
10468
-
10469
10452
// Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons
10470
10453
// for 5 or more occurrences or instantiations of the type have been recorded on the given stack. It is possible,
10471
10454
// though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely
@@ -13767,7 +13750,7 @@ namespace ts {
13767
13750
// the contextual type of an initializer expression is the type annotation of the containing declaration, if present.
13768
13751
function getContextualTypeForInitializerExpression(node: Expression): Type {
13769
13752
const declaration = <VariableLikeDeclaration>node.parent;
13770
- if (node === declaration.initializer) {
13753
+ if (node === declaration.initializer || node.kind === SyntaxKind.EqualsToken ) {
13771
13754
const typeNode = getEffectiveTypeAnnotationNode(declaration);
13772
13755
if (typeNode) {
13773
13756
return getTypeFromTypeNode(typeNode);
@@ -13899,6 +13882,12 @@ namespace ts {
13899
13882
case SyntaxKind.AmpersandAmpersandToken:
13900
13883
case SyntaxKind.CommaToken:
13901
13884
return node === right ? getContextualType(binaryExpression) : undefined;
13885
+ case SyntaxKind.EqualsEqualsEqualsToken:
13886
+ case SyntaxKind.EqualsEqualsToken:
13887
+ case SyntaxKind.ExclamationEqualsEqualsToken:
13888
+ case SyntaxKind.ExclamationEqualsToken:
13889
+ // For completions after `x === `
13890
+ return node === operatorToken ? getTypeOfExpression(binaryExpression.left) : undefined;
13902
13891
default:
13903
13892
return undefined;
13904
13893
}
@@ -14114,9 +14103,13 @@ namespace ts {
14114
14103
return getContextualTypeForReturnExpression(node);
14115
14104
case SyntaxKind.YieldExpression:
14116
14105
return getContextualTypeForYieldOperand(<YieldExpression>parent);
14117
- case SyntaxKind.CallExpression:
14118
14106
case SyntaxKind.NewExpression:
14119
- return getContextualTypeForArgument(<CallExpression>parent, node);
14107
+ if (node.kind === SyntaxKind.NewKeyword) { // for completions after `new `
14108
+ return getContextualType(parent as NewExpression);
14109
+ }
14110
+ // falls through
14111
+ case SyntaxKind.CallExpression:
14112
+ return getContextualTypeForArgument(<CallExpression | NewExpression>parent, node);
14120
14113
case SyntaxKind.TypeAssertionExpression:
14121
14114
case SyntaxKind.AsExpression:
14122
14115
return getTypeFromTypeNode((<AssertionExpression>parent).type);
@@ -14150,6 +14143,12 @@ namespace ts {
14150
14143
case SyntaxKind.JsxOpeningElement:
14151
14144
case SyntaxKind.JsxSelfClosingElement:
14152
14145
return getAttributesTypeFromJsxOpeningLikeElement(<JsxOpeningLikeElement>parent);
14146
+ case SyntaxKind.CaseClause: {
14147
+ if (node.kind === SyntaxKind.CaseKeyword) { // for completions after `case `
14148
+ const switchStatement = (parent as CaseClause).parent.parent;
14149
+ return getTypeOfExpression(switchStatement.expression);
14150
+ }
14151
+ }
14153
14152
}
14154
14153
return undefined;
14155
14154
}
@@ -22578,10 +22577,6 @@ namespace ts {
22578
22577
return getCheckFlags(s) & CheckFlags.Instantiated ? (<TransientSymbol>s).target : s;
22579
22578
}
22580
22579
22581
- function getClassLikeDeclarationOfSymbol(symbol: Symbol): Declaration {
22582
- return forEach(symbol.declarations, d => isClassLike(d) ? d : undefined);
22583
- }
22584
-
22585
22580
function getClassOrInterfaceDeclarationsOfSymbol(symbol: Symbol) {
22586
22581
return filter(symbol.declarations, (d: Declaration): d is ClassDeclaration | InterfaceDeclaration =>
22587
22582
d.kind === SyntaxKind.ClassDeclaration || d.kind === SyntaxKind.InterfaceDeclaration);
0 commit comments