Skip to content
RED SAG Skills
hardStudy question · answer published in JavaScript interview questions, so no pointsjavascripttypescriptconditional-types

Extracting a type with infer

What type does Item resolve to?

type ElementOf<T> = T extends readonly (infer U)[] ? U : never
const cart = [{ sku: "A1", qty: 2 }]
type Item = ElementOf<typeof cart>
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions