Skip to content

Prevent false assignability success in deeply nested array object types#32

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-issue-52912-yet-again
Draft

Prevent false assignability success in deeply nested array object types#32
Copilot wants to merge 4 commits intomainfrom
copilot/fix-issue-52912-yet-again

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 16, 2026

Type relationships with nested array wrappers could be incorrectly accepted, allowing incompatible programs depending on comparison order.
This change tightens recursion identity handling for array references so finite nested object/array structures are fully checked instead of being short-circuited as “deep recursion”.

  • Checker update

    • In getRecursionIdentity, array type references now recurse through the element type identity rather than using the shared global Array symbol identity.
    • This avoids false deep-nesting classification for common finite array wrappers, preventing incorrect Ternary.Maybe/cache success paths in assignability checks.
  • Regression test

    • Added tests/cases/compiler/issue52912.ts with the reported SourceN/TargetN nested-array repro.
    • Added corresponding baselines to lock expected errors at all nesting levels.
  • Example (now correctly rejected)

type Source1 = { array: Source2[] };
type Source2 = { array: Source3[] };
type Source3 = { array: Source4[] };
type Source4 = {};

type Target1 = { array: Target2[] };
type Target2 = { array: Target3[] };
type Target3 = { array: Target4[] };
type Target4 = { someNewProperty: string };

declare const source1: Source1;
const target1: Target1 = source1; // now errors

Copilot AI and others added 4 commits April 16, 2026 19:38
Agent-Logs-Url: https://github.com/RyanCavanaugh/TypeScript/sessions/dee5edef-e472-4317-8876-e1ca781fb3bf

Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Agent-Logs-Url: https://github.com/RyanCavanaugh/TypeScript/sessions/dee5edef-e472-4317-8876-e1ca781fb3bf

Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants