Practice question from Advanced Typescript

What does the infer keyword do in this conditional type? A. Creates a new type variable B. Defines a generic type C. Allows type inference in conditional types D. Creates a union type E. Restricts type parameters

type ExtractFirst<T> = T extends [infer U, ...any[]] ? U : never;

Answer

C

Explanation

The infer keyword allows dynamic type inference within conditional types

More questions from Quick: Advanced Typescript