Skip to content

Commit 4515089

Browse files
authored
Fixed a crash in completions on functionlike types (microsoft#56257)
1 parent 3333e90 commit 4515089

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1868,7 +1868,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
18681868
const nodeLinks = getNodeLinks(node);
18691869
cachedResolvedSignatures.push([nodeLinks, nodeLinks.resolvedSignature] as const);
18701870
nodeLinks.resolvedSignature = undefined;
1871-
if (isFunctionLike(node)) {
1871+
if (isFunctionExpressionOrArrowFunction(node)) {
18721872
const symbolLinks = getSymbolLinks(getSymbolOfDeclaration(node));
18731873
const type = symbolLinks.type;
18741874
cachedTypes.push([symbolLinks, type] as const);

src/compiler/utilitiesPublic.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ArrayBindingElement,
66
ArrayBindingOrAssignmentElement,
77
ArrayBindingOrAssignmentPattern,
8+
ArrowFunction,
89
AssertionExpression,
910
AssignmentDeclarationKind,
1011
AssignmentPattern,
@@ -64,6 +65,7 @@ import {
6465
ForInitializer,
6566
ForInOrOfStatement,
6667
FunctionBody,
68+
FunctionExpression,
6769
FunctionLikeDeclaration,
6870
FunctionTypeNode,
6971
GeneratedIdentifier,
@@ -119,6 +121,7 @@ import {
119121
isExportSpecifier,
120122
isFunctionBlock,
121123
isFunctionExpression,
124+
isFunctionExpressionOrArrowFunction,
122125
isFunctionTypeNode,
123126
isIdentifier,
124127
isImportSpecifier,
@@ -1928,8 +1931,8 @@ export function isPropertyAccessOrQualifiedName(node: Node): node is PropertyAcc
19281931
}
19291932

19301933
/** @internal */
1931-
export function isCallLikeOrFunctionLikeExpression(node: Node): node is CallLikeExpression | SignatureDeclaration {
1932-
return isCallLikeExpression(node) || isFunctionLike(node);
1934+
export function isCallLikeOrFunctionLikeExpression(node: Node): node is CallLikeExpression | FunctionExpression | ArrowFunction {
1935+
return isCallLikeExpression(node) || isFunctionExpressionOrArrowFunction(node);
19331936
}
19341937

19351938
export function isCallLikeExpression(node: Node): node is CallLikeExpression {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
///<reference path="fourslash.ts" />
2+
3+
//// /**
4+
//// * @returns {function/**/(): string}
5+
//// */
6+
//// function updateCalendarEvent() {
7+
//// return "";
8+
//// }
9+
10+
verify.completions({
11+
marker: "",
12+
exact: completion.globalTypes
13+
});

0 commit comments

Comments
 (0)