Skip to content

Include inferred usages in 'find references' #12685

Closed
@OliverJAsh

Description

@OliverJAsh
type Child = { name: string }
type Parent = { children: Child[] }
const createParent = (): Parent => (
  { children: ['foo', 'bar']
    .map((name) => ({ name }))
  }
)

TS is type-checking Parent, which involves type checking the children property and thus each `Child.

When I select name inside my Array mapper function and invoke TS to find references, VSCode/TypeScript server does not include the original type definition of Child.name:

image

(See Child.name is not highlighted).

However, if I add the type annotation for Child, it does include it in the list of references:

type Child = { name: string }
type Parent = { children: Child[] }
const createParent = (): Parent => (
  { children: ['foo', 'bar']
    .map((name): Child => ({ name }))
  }
)

image

Would it be possible to make TypeScript include the references that are inferred instead of annotated, e.g. example 1 as well as example 2?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixedSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions