Skip to content

Incorrect report of self-referencing type for static fieldsΒ #62552

@boris-kolar

Description

@boris-kolar

πŸ”Ž 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionHelp WantedYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some cases

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions