Fix stack overflow on circular reference after satisfies#3807
Conversation
When checkSatisfiesExpression is re-entered via getTypeOfExpression (with CheckModeTypeOnly), skip the type assignability check that triggers error reporting. Error reporting during type serialization would re-evaluate the satisfies expression, causing infinite recursion. The assignability check only produces errors and doesn't affect the return type (always exprType), so skipping it when CheckModeTypeOnly is set is safe. Fixes #3805 Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/f221297f-bd44-447e-965b-fc7b35362b61 Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
satisfies
|
@copilot is this a porting bug? If not why doesn't Strada hit this? |
Yes, this is a porting bug. Strada doesn't hit this because it doesn't have the pseudochecker path. The cycle is: In Strada, |
const f = () => 42 satisfies typeof fcauses a stack overflow due to infinite recursion betweencheckSatisfiesExpression→ error reporting →typeToString→serializeReturnTypeForSignature→pseudoTypeToType→getRegularTypeOfExpression→checkExpressionEx→checkSatisfiesExpression.The satisfies check fails (
numbervs() => any), triggers error reporting, which serializes the function type, which re-evaluates the satisfies expression, which fails again, ad infinitum.checkModethrough tocheckSatisfiesExpressionand skip the assignability check whenCheckModeTypeOnlyis set (the mode used bygetTypeOfExpressionin the serialization path). The check is purely diagnostic—exprTypeis always returned regardless of the result.Now correctly produces the expected errors: