@@ -256,6 +256,7 @@ namespace ts {
256256 return resolveName(location, escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
257257 },
258258 getJsxNamespace: () => unescapeLeadingUnderscores(getJsxNamespace()),
259+ getAccessibleSymbolChain,
259260 };
260261
261262 const tupleTypes: GenericType[] = [];
@@ -763,10 +764,6 @@ namespace ts {
763764 return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 });
764765 }
765766
766- function getObjectFlags(type: Type): ObjectFlags {
767- return type.flags & TypeFlags.Object ? (<ObjectType>type).objectFlags : 0;
768- }
769-
770767 function isGlobalSourceFile(node: Node) {
771768 return node.kind === SyntaxKind.SourceFile && !isExternalOrCommonJsModule(<SourceFile>node);
772769 }
@@ -10452,20 +10449,6 @@ namespace ts {
1045210449 !hasBaseType(checkClass, getDeclaringClass(p)) : false) ? undefined : checkClass;
1045310450 }
1045410451
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-
1046910452 // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons
1047010453 // for 5 or more occurrences or instantiations of the type have been recorded on the given stack. It is possible,
1047110454 // 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 {
1376713750 // the contextual type of an initializer expression is the type annotation of the containing declaration, if present.
1376813751 function getContextualTypeForInitializerExpression(node: Expression): Type {
1376913752 const declaration = <VariableLikeDeclaration>node.parent;
13770- if (node === declaration.initializer) {
13753+ if (node === declaration.initializer || node.kind === SyntaxKind.EqualsToken ) {
1377113754 const typeNode = getEffectiveTypeAnnotationNode(declaration);
1377213755 if (typeNode) {
1377313756 return getTypeFromTypeNode(typeNode);
@@ -13899,6 +13882,12 @@ namespace ts {
1389913882 case SyntaxKind.AmpersandAmpersandToken:
1390013883 case SyntaxKind.CommaToken:
1390113884 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;
1390213891 default:
1390313892 return undefined;
1390413893 }
@@ -14114,9 +14103,13 @@ namespace ts {
1411414103 return getContextualTypeForReturnExpression(node);
1411514104 case SyntaxKind.YieldExpression:
1411614105 return getContextualTypeForYieldOperand(<YieldExpression>parent);
14117- case SyntaxKind.CallExpression:
1411814106 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);
1412014113 case SyntaxKind.TypeAssertionExpression:
1412114114 case SyntaxKind.AsExpression:
1412214115 return getTypeFromTypeNode((<AssertionExpression>parent).type);
@@ -14150,6 +14143,12 @@ namespace ts {
1415014143 case SyntaxKind.JsxOpeningElement:
1415114144 case SyntaxKind.JsxSelfClosingElement:
1415214145 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+ }
1415314152 }
1415414153 return undefined;
1415514154 }
@@ -22578,10 +22577,6 @@ namespace ts {
2257822577 return getCheckFlags(s) & CheckFlags.Instantiated ? (<TransientSymbol>s).target : s;
2257922578 }
2258022579
22581- function getClassLikeDeclarationOfSymbol(symbol: Symbol): Declaration {
22582- return forEach(symbol.declarations, d => isClassLike(d) ? d : undefined);
22583- }
22584-
2258522580 function getClassOrInterfaceDeclarationsOfSymbol(symbol: Symbol) {
2258622581 return filter(symbol.declarations, (d: Declaration): d is ClassDeclaration | InterfaceDeclaration =>
2258722582 d.kind === SyntaxKind.ClassDeclaration || d.kind === SyntaxKind.InterfaceDeclaration);
0 commit comments