microsoft / microsoft/TypeScript
Incorrect report of self-referencing type for static fields
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
### 🔎 Search Terms
TS7022
implicitly has type 'any'
### 🕗 Version & Regression Information
- The issue applies to all TypeScript 5 versions and TypeScript 6 nightly
### ⏯ Playground Link
https://www.typescriptlang.org/play/?ts=6.0.0-dev.20251006#code/GYVwdgxgLglg9mABDAJgHgCoD4AUAPALkQwEoiNEBvAKEUQCcBTKEepPagX2uogQGcoiAGJw4iALzIUOCABsAhv35VaiQQtgQGjBSgRyAnomBjJ0nABYATCUQB6e4gCi9enHrEAygHYADNbWXCQ8fGCCiADyANbm8koqNHQaWjp6Bsam4lKoVrYOTgBy4oxuHlzUQA
### 💻 Code
```ts
function id(x: T): T {
return x
}
const Foo = id(class {
static readonly foo = id(42) // Error TS7022
})
const Ok = class {
static readonly foo = id(42) // No error
}
```
### 🙁 Actual behavior
Type error TS7022 reported
### 🙂 Expected behavior
No type error
### Additional information about the issue
_No response_
贡献指南
调研方向
从链接的 TypeScript Playground 开始,使用两个类示例重现 TS7022 诊断。比较自引用静态字段与等效独立类之间的诊断行为,然后跟踪编译器的类型推断和诊断路径。当所报告的示例不再产生 TS7022,同时相关错误行为保持不变时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100