-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixedSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
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:
(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 }))
}
)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
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixedSuggestionAn idea for TypeScriptAn idea for TypeScript

