โœ•
โœ๏ธ Content byMd. Rakibul Islam
๐ŸŽฏ
MCQ
Multiple Choice ยท 8 questions
1Hardconditional typesโฑ 45s

What is the result of this conditional type?

โ–ผ
typescript
type IsArray<T> = T extends any[] ? 'array' : 'not array';
type A = IsArray<string[]>;
type B = IsArray<number>;
2Hardmapped typesโฑ 50s

What does this mapped type produce?

โ–ผ
typescript
type Nullable<T> = { [K in keyof T]: T[K] | null };
type User = { name: string; age: number };
type NullableUser = Nullable<User>;
3Hardinferโฑ 60s

What does the 'infer' keyword do in conditional types?

โ–ผ
typescript
type ReturnType<T> = T extends (...args: any[]) => infer R ? R : never;
type Result = ReturnType<() => { id: number; name: string }>;
4Harddiscriminated unionsโฑ 50s

What is a discriminated union and what makes it work?

โ–ผ
typescript
type Shape = 
  | { kind: 'circle'; radius: number }
  | { kind: 'rect'; width: number; height: number };

function area(s: Shape) {
  switch (s.kind) {
    case 'circle': return Math.PI * s.radius ** 2;
    case 'rect':   return s.width * s.height;
  }
}
5Harddeclaration mergingโฑ 45s

What does declaration merging allow in TypeScript?

โ–ผ
typescript
interface Window {
  myPlugin: { version: string };
}

// Now window.myPlugin is typed!
declare const window: Window;
window.myPlugin.version; // no error
6Hardsatisfiesโฑ 60s

What does the 'satisfies' operator do in TypeScript 4.9+?

โ–ผ
typescript
const palette = {
  red: [255, 0, 0],
  green: '#00ff00',
} satisfies Record<string, string | number[]>;

palette.red.map(x => x); // works! red is inferred as number[]
palette.green.toUpperCase(); // works! green is inferred as string
7Hardutility typesโฑ 40s

What is the difference between Partial<T>, Required<T>, and Pick<T, K>?

โ–ผ
8Hardtemplate literal typesโฑ 50s

What does this template literal type produce?

โ–ผ
typescript
type EventName = 'click' | 'focus' | 'blur';
type Handler = `on${Capitalize<EventName>}`;
Typescript MCQ Interview Questions โ€” All Levels | UyTech