mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-02 14:48:32 -05:00
feat(7481): Operator to ensure an expression is contextually typed by, and satisfies, some type (#46827)
* feat(7481): add explicit type compatibility check with 'satisfies' expression * Add failing test for lack of intersectioned contextual type * Implement the behavior * Add test corresponding to the 'if' * Add test based on defined scenarios * remove isExpression in favor of using type casting * move tests from compiler to conformance folder * update baseline * add missing contextFlags argument * use asserted type * accept baseline Co-authored-by: Ryan Cavanaugh <ryanca@microsoft.com>
This commit is contained in:
@@ -2372,6 +2372,9 @@ namespace ts {
|
||||
case SyntaxKind.AsExpression:
|
||||
diagnostics.push(createDiagnosticForNode((node as AsExpression).type, Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files));
|
||||
return "skip";
|
||||
case SyntaxKind.SatisfiesExpression:
|
||||
diagnostics.push(createDiagnosticForNode((node as SatisfiesExpression).type, Diagnostics.Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files));
|
||||
return "skip";
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user