mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-16 07:13:43 -05:00
Report assignability errors on the satisfies keyword (#53797)
This commit is contained in:
committed by
GitHub
parent
bdcf8abb0c
commit
5897d7a135
@@ -34618,7 +34618,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
if (isErrorType(targetType)) {
|
||||
return targetType;
|
||||
}
|
||||
checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, target, expression, Diagnostics.Type_0_does_not_satisfy_the_expected_type_1);
|
||||
const errorNode = findAncestor(target.parent, n => n.kind === SyntaxKind.SatisfiesExpression || n.kind === SyntaxKind.JSDocSatisfiesTag);
|
||||
checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, errorNode, expression, Diagnostics.Type_0_does_not_satisfy_the_expected_type_1);
|
||||
return exprType;
|
||||
}
|
||||
|
||||
|
||||
@@ -350,6 +350,7 @@ import {
|
||||
JSDocParameterTag,
|
||||
JSDocPropertyLikeTag,
|
||||
JSDocSatisfiesExpression,
|
||||
JSDocSatisfiesTag,
|
||||
JSDocSignature,
|
||||
JSDocTag,
|
||||
JSDocTemplateTag,
|
||||
@@ -2234,6 +2235,14 @@ export function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpa
|
||||
const pos = skipTrivia(sourceFile.text, (node as ReturnStatement | YieldExpression).pos);
|
||||
return getSpanOfTokenAtPosition(sourceFile, pos);
|
||||
}
|
||||
case SyntaxKind.SatisfiesExpression: {
|
||||
const pos = skipTrivia(sourceFile.text, (node as SatisfiesExpression).expression.end);
|
||||
return getSpanOfTokenAtPosition(sourceFile, pos);
|
||||
}
|
||||
case SyntaxKind.JSDocSatisfiesTag: {
|
||||
const pos = skipTrivia(sourceFile.text, (node as JSDocSatisfiesTag).tagName.pos);
|
||||
return getSpanOfTokenAtPosition(sourceFile, pos);
|
||||
}
|
||||
}
|
||||
|
||||
if (errorNode === undefined) {
|
||||
|
||||
Reference in New Issue
Block a user