microsoft / microsoft/TypeScript

tagged/named rest parameter participating in circular reference causes error

Open
#63,584 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: check: Type Circularity
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

### 🔎 Search Terms

named tuple element rest recursive circularly references union unions

### 🕗 Version & Regression Information

- This is the behavior in every version I tried, and I reviewed the FAQ for entries about *everything and didn't find anything relevant*

### ⏯ Playground Link

https://www.typescriptlang.org/play/?esModuleInterop=false&target=99&jsx=0&noFallthroughCasesInSwitch=false&ts=6.0.0-dev.20260416&noUnusedLocals=true&noUnusedParameters=true&noUncheckedIndexedAccess=true#code/KYDwDg9gTgLgBDAnmYcDiEIBMAiEDGActqgLwBQcVcAPnAM4xQCWAdgOaXV0DaARMz4AaOADpxGbHiIkeAXTlcqvPgBtBItllAAuOKwCuAWwBGwKCPGjJuAsW3y5AbnLlQkWAmSoAQgENbGW0ARjgKaloGJjZOCJUNMXEYP3Z2YCw9f0D7YGDHcgB6AoiSiIA9CsqKpUj+dWE4LV19YzMLRNEs6Ry8hRc3cGh4JBQ4LrsSACYwmrpGFg5ZuH4Eq3Gg4En8uOW1BKaQPUNTc0sklLSMsYDuqccXItKn5+eqqvIgA

### 💻 Code

```ts
export type GoodDocNode =
| string
| ["i", ...GoodDocNode[]]
| ["li", index: number, ...GoodDocNode[]];

export type BadDocNode1 =
| string
| ["i", ...tagged: BadDocNode1[]]
// ^^^^^^^^
| ["li", index: number, ...BadDocNode1[]];

export type BadDocNode2 =
| string
| ["i", ...BadDocNode2[]]
| ["li", index: number, ...tagged: BadDocNode2[]];
// ^^^^^^^^
```

### 🙁 Actual behavior

Error:
```
Type alias 'BadDocNode1' circularly references itself.
Type alias 'BadDocNode2' circularly references itself.
```

### 🙂 Expected behavior

No errors, because the only differences between the two is the name on the rest parameter in the tuple, nothing structurally is different.

### Additional information about the issue

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the linked TypeScript Playground and the BadDocNode1/BadDocNode2 repro as the starting point; investigate circular type-alias checking for named tuple rest parameters. Done means the repro produces no circular-reference errors while the structurally equivalent GoodDocNode example remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.