microsoft / microsoft/TypeScript

tagged/named rest parameter participating in circular reference causes error

未关闭
#63,584 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
Bug Domain: check: Type Circularity
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
132

描述

### 🔎 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_

贡献指南

打开贡献指南

调研方向

以链接的 TypeScript Playground 和 BadDocNode1/BadDocNode2 复现作为起点;调查命名元组 rest 参数的循环类型别名检查。完成标准是复现不产生循环引用错误,同时结构等价的 GoodDocNode 示例仍然有效。

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
compilers
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
描述清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。