Skip to content

Enable to infer the parameter's type correctly in this case. Why? #62026

Closed as not planned
@TonyL1u

Description

@TonyL1u

TS version: 4.9.5
playground

type A1 = {
  key: 'id'
  type: 'date'
  format?: string
}

type A2 = {
  key: 'id'
  value?: (v: number) => any
}

type A3 = {
  key: 'name'
  value?: (v: string) => any
}

const obj: A1 | A2 | A3 = {
  key: 'id',
  value: v => v // Parameter 'v' implicitly has an 'any' type.(7006)
}

When I try to upgrade the TS version to 5.1.6, problem solved.
Is there any solutions to solve this problem without upgrading the TS version?

Metadata

Metadata

Assignees

No one assigned

    Labels

    UnactionableThere isn't something we can do with this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions