Microsoft/TypeScript

Incorrect report of self-referencing type for static fields

Open

#62 552 ouverte le 6 oct. 2025

Voir sur GitHub
 (0 commentaires) (0 réactions) (0 assignés)TypeScript (6 726 forks)batch import
Domain: check: Type InferenceHelp WantedPossible Improvement

Métriques du dépôt

Stars
 (48 455 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (9 PRs mergées en 30 j)

Description

🔎 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

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

Guide contributeur