From 0009f7fe596f1642f58485b55cc82a58203f3b77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 30 Oct 2023 23:04:39 +0100 Subject: [PATCH] Tighten checks even more --- src/compiler/checker.ts | 2 +- src/compiler/utilitiesPublic.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index acc0666333e4f..3c6217180981a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1868,7 +1868,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const nodeLinks = getNodeLinks(node); cachedResolvedSignatures.push([nodeLinks, nodeLinks.resolvedSignature] as const); nodeLinks.resolvedSignature = undefined; - if (isFunctionLikeDeclaration(node)) { + if (isFunctionExpressionOrArrowFunction(node)) { const symbolLinks = getSymbolLinks(getSymbolOfDeclaration(node)); const type = symbolLinks.type; cachedTypes.push([symbolLinks, type] as const); diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index b7cdef568277c..688ef16272039 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -5,6 +5,7 @@ import { ArrayBindingElement, ArrayBindingOrAssignmentElement, ArrayBindingOrAssignmentPattern, + ArrowFunction, AssertionExpression, AssignmentDeclarationKind, AssignmentPattern, @@ -64,6 +65,7 @@ import { ForInitializer, ForInOrOfStatement, FunctionBody, + FunctionExpression, FunctionLikeDeclaration, FunctionTypeNode, GeneratedIdentifier, @@ -119,6 +121,7 @@ import { isExportSpecifier, isFunctionBlock, isFunctionExpression, + isFunctionExpressionOrArrowFunction, isFunctionTypeNode, isIdentifier, isImportSpecifier, @@ -1928,8 +1931,8 @@ export function isPropertyAccessOrQualifiedName(node: Node): node is PropertyAcc } /** @internal */ -export function isCallLikeOrFunctionLikeExpression(node: Node): node is CallLikeExpression | FunctionLikeDeclaration { - return isCallLikeExpression(node) || isFunctionLikeDeclaration(node); +export function isCallLikeOrFunctionLikeExpression(node: Node): node is CallLikeExpression | FunctionExpression | ArrowFunction { + return isCallLikeExpression(node) || isFunctionExpressionOrArrowFunction(node); } export function isCallLikeExpression(node: Node): node is CallLikeExpression {