File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -21698,15 +21698,19 @@ namespace ts {
21698
21698
* to cache the result.
21699
21699
*/
21700
21700
function getTypeOfExpression(node: Expression, cache?: boolean) {
21701
+ const expr = skipParentheses(node);
21701
21702
// Optimize for the common case of a call to a function with a single non-generic call
21702
21703
// signature where we can just fetch the return type without checking the arguments.
21703
- if (node .kind === SyntaxKind.CallExpression && (<CallExpression>node ).expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(node , /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node )) {
21704
- const funcType = checkNonNullExpression((<CallExpression>node ).expression);
21704
+ if (expr .kind === SyntaxKind.CallExpression && (<CallExpression>expr ).expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(expr , /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr )) {
21705
+ const funcType = checkNonNullExpression((<CallExpression>expr ).expression);
21705
21706
const signature = getSingleCallSignature(funcType);
21706
21707
if (signature && !signature.typeParameters) {
21707
21708
return getReturnTypeOfSignature(signature);
21708
21709
}
21709
21710
}
21711
+ else if (expr.kind === SyntaxKind.TypeAssertionExpression || expr.kind === SyntaxKind.AsExpression) {
21712
+ return getTypeFromTypeNode((<TypeAssertion>expr).type);
21713
+ }
21710
21714
// Otherwise simply call checkExpression. Ideally, the entire family of checkXXX functions
21711
21715
// should have a parameter that indicates whether full error checking is required such that
21712
21716
// we can perform the optimizations locally.
You can’t perform that action at this time.
0 commit comments