Microsoft/TypeScript
在 GitHub 查看Incorrect report of self-referencing type for static fields
Open
#62,552 创建于 2025年10月6日
Domain: check: Type InferenceHelp WantedPossible Improvement
仓库指标
- Star
- (48,455 star)
- PR 合并指标
- (平均合并 6天 17小时) (30 天内合并 9 个 PR)
描述
🔎 Search Terms
TS7022 implicitly has type 'any'
🕗 Version & Regression Information
- The issue applies to all TypeScript 5 versions and TypeScript 6 nightly
⏯ Playground Link
💻 Code
function id<T>(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