mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Cache expression type when checking assertion (#54224)
This commit is contained in:
parent
f0ff97611f
commit
48328caa71
@ -34523,6 +34523,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
return getRegularTypeOfLiteralType(exprType);
|
||||
}
|
||||
const links = getNodeLinks(node);
|
||||
links.assertionExpressionType = exprType;
|
||||
checkSourceElement(type);
|
||||
checkNodeDeferred(node);
|
||||
return getTypeFromTypeNode(type);
|
||||
@ -34547,9 +34549,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
|
||||
function checkAssertionDeferred(node: JSDocTypeAssertion | AssertionExpression) {
|
||||
const { type, expression } = getAssertionTypeAndExpression(node);
|
||||
const { type } = getAssertionTypeAndExpression(node);
|
||||
const errNode = isParenthesizedExpression(node) ? type : node;
|
||||
const exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(checkExpression(expression)));
|
||||
const links = getNodeLinks(node);
|
||||
Debug.assertIsDefined(links.assertionExpressionType);
|
||||
const exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(links.assertionExpressionType));
|
||||
const targetType = getTypeFromTypeNode(type);
|
||||
if (!isErrorType(targetType)) {
|
||||
addLazyDiagnostic(() => {
|
||||
|
||||
@ -6060,6 +6060,7 @@ export interface NodeLinks {
|
||||
spreadIndices?: { first: number | undefined, last: number | undefined }; // Indices of first and last spread elements in array literal
|
||||
parameterInitializerContainsUndefined?: boolean; // True if this is a parameter declaration whose type annotation contains "undefined".
|
||||
fakeScopeForSignatureDeclaration?: boolean; // True if this is a fake scope injected into an enclosing declaration chain.
|
||||
assertionExpressionType?: Type; // Cached type of the expression of a type assertion
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user