What does TypeScript’s ‘resolution-mode’ import attribute enable in moduleResolution: bundler mode? TypeScript ProfessionalHard Try Now
What does the following type produce and how does it work? type Zip = T extends [infer TH, …infer TT] ? U extends [infer UH, …infer UT] ? [[TH, UH], …Zip] : [] : []; TypeScript ProfessionalHard Try Now
What does the following TypeScript 4.1+ template literal type produce? type PropEventSource = { on(event: `${K}Changed`, callback: (value: T[K]) => void): void; }; TypeScript ProfessionalHard Try Now
What does the following ‘using’ and ‘Symbol.dispose’ pattern guarantee? class DbConnection { [Symbol.dispose]() { this.close(); } close() { /* cleanup */ } } { using conn = new DbConnection(); // use conn } TypeScript ProfessionalHard Try Now
What does ‘bivariant’ method checking mean and when does TypeScript use it? TypeScript ProfessionalHard Try Now
What does the following declaration merge between a namespace and a class enable? class Animal { name: string = ”; } namespace Animal { export function create(name: string): Animal { const a = new Animal(); a.name = name; return a; } } TypeScript ProfessionalHard Try Now
What does the following type guard pattern enable that ‘as’ casting does not? function isUser(value: unknown): value is User { return typeof value === ‘object’ && value !== null && ‘id’ in value; } TypeScript ProfessionalHard Try Now
What issue does the following TypeScript pattern address? type StrictOmit = Omit; TypeScript ProfessionalHard Try Now
What does the following generic function demonstrate about TypeScript’s ‘infer in conditional return types’? type Unbox = T extends { value: infer V } ? V : never; type Result = Unbox; TypeScript ProfessionalHard Try Now
What does TypeScript’s ‘exactOptionalPropertyTypes’ flag change about the following type? interface Config { timeout?: number; } TypeScript ProfessionalHard Try Now
What does the following type-level string manipulation compute? type CamelToSnake = S extends `${infer Head}${infer Tail}` ? Head extends Uppercase ? `_${Lowercase}${CamelToSnake}` : `${Head}${CamelToSnake}` : S; TypeScript ProfessionalHard Try Now
What does the following type implement and what is it useful for? type Opaque = T & { readonly __brand: Brand }; type UserId = Opaque; type ProductId = Opaque; TypeScript ProfessionalHard Try Now
What does the following ‘infer’ usage extract? type PromiseValue = T extends Promise ? PromiseValue : T; TypeScript ProfessionalHard Try Now
What does TypeScript’s ‘using await’ (async explicit resource management) enable differently from regular ‘using’? TypeScript ProfessionalHard Try Now
What does the following function overload pattern enable? function process(input: string): string; function process(input: number): number; function process(input: string | number): string | number { return input; } TypeScript ProfessionalHard Try Now
What is the difference between ‘interface’ declaration merging and type alias intersection when both add the same property with incompatible types? TypeScript ProfessionalHard Try Now
What does the following type utility compute? type DeepPartial = T extends object ? { [K in keyof T]?: DeepPartial } : T; TypeScript ProfessionalHard Try Now
What does the following module augmentation achieve? // In express.d.ts import ‘express’; declare module ‘express’ { interface Request { user?: { id: string }; } } TypeScript ProfessionalHard Try Now