What does the following generic constraint pattern achieve? type Covariant = () => T; type Contravariant = (arg: T) => void; // Which is wider: Covariant or Covariant if Dog extends Animal? TypeScript ProfessionalHard Try Now
What does the following type achieve and what is its practical use? type Simplify = T extends infer O ? { [K in keyof O]: O[K] } : never; TypeScript ProfessionalHard Try Now
What does this declaration show about TypeScript’s ‘this’ parameter? function toArray(this: { items: number[] }): number[] { return this.items; } TypeScript ProfessionalHard Try Now
What does the following ‘const’ type parameter (TypeScript 5.0) infer? function identity(value: T): T { return value; } const result = identity({ x: 1, y: ‘hello’ }); TypeScript ProfessionalHard Try Now
What does the following mapped type with key filtering produce? type FunctionProperties = { [K in keyof T as T[K] extends Function ? K : never]: T[K] }; TypeScript ProfessionalHard Try Now
What does the following conditional type produce for T = string | number? type StringOnly = T extends string ? T : never; type Result = StringOnly; TypeScript ProfessionalHard Try Now
What is a ‘higher-kinded type’ and why can’t TypeScript natively represent it? TypeScript ProfessionalHard Try Now
What does this type-level programming pattern produce? type LastOf = UnionToIntersection T : never> extends () => infer R ? R : never; TypeScript ProfessionalHard Try Now
What does the following decorator factory pattern achieve in TypeScript 5.0 stage-3 decorators? function log(target: any, context: ClassMethodDecoratorContext) { return function(this: any, …args: any[]) { console.log(`Calling ${String(context.name)}`); return target.call(this, …args); }; } TypeScript ProfessionalHard Try Now
What is the difference between ‘abstract new (…args: any[]) => T’ and ‘new (…args: any[]) => T’ as a type? TypeScript ProfessionalHard Try Now
What does the following pattern achieve? type Prettify = { [K in keyof T]: T[K] } & {}; TypeScript ProfessionalHard Try Now
What does ‘asserts condition’ as a function return type enable in TypeScript? TypeScript ProfessionalHard Try Now
What does the following type-level Fibonacci implementation use? type BuildArr = Arr[‘length’] extends N ? Arr : BuildArr; type Add = […BuildArr, …BuildArr][‘length’]; TypeScript ProfessionalHard Try Now
What does the following variadic tuple type compute? type Concat = […A, …B]; TypeScript ProfessionalHard Try Now
What is the difference between distributive and non-distributive conditional types, and how do you create the latter? TypeScript ProfessionalHard Try Now
What does the following type produce for IsNever and IsNever? type IsNever = [T] extends [never] ? true : false; TypeScript ProfessionalHard Try Now
What does the following recursive type compute? type TupleLength = T extends [any, …infer Rest] ? TupleLength : Acc[‘length’]; TypeScript ProfessionalHard Try Now
What does the following type compute and what technique does it use? type UnionToIntersection = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never; TypeScript ProfessionalHard Try Now