What does `BoxCtor` represent, and which expression below is therefore valid?
class Box {
value = 0;
static make() { return new Box(); }
}
type BoxCtor = typeof Box;Read the full question →TypeScript adds a structural type system on top of JavaScript. Most of the difficulty sits in what the compiler infers, not in what you wrote.
Expect inference puzzles: conditional types, mapped types, variance on function parameters, and when a union distributes. A large share of questions are literally 'what is the inferred type here'.
Where it shows up: Product engineering teams that outgrew plain JavaScript, design-system work, and any codebase large enough to need refactor safety.
Twenty real TypeScript questions from the library, code snippet included. Nothing here is paraphrased for search engines. It is the same text a signed-in user sees.
class Box {
value = 0;
static make() { return new Box(); }
}
type BoxCtor = typeof Box;Read the full question →const arr: number[] = [1,2,3];\nconst x = arr[0]; // with noUncheckedIndexedAccessRead the full question →type X = `${Capitalize<"foo">}Bar`;Read the full question →const f = (x: number) => x + 1;Read the full question →type X = string & number;Read the full question →let x = 5;Read the full question →function distance(point: { x: number; y: number }): number {
return Math.sqrt(point.x ** 2 + point.y ** 2);
}Read the full question →type X = Exclude<"a"|"b","a"|"b">;Read the full question →type ToArray<T> = T extends unknown ? T[] : never;
type R = ToArray<string | never>;Read the full question →type Result = keyof ({ a: 1; b: 2 } | { b: 3; c: 4 });Read the full question →interface Animal { type: string }
interface Dog extends Animal { type: "dog"; bark(): void }
function isDog(a: Animal): a is Dog { return a.type === "dog"; }
function looksDog(a: Animal): boolean { return a.type === "dog"; }
declare const an2: Animal;
if (looksDog(an2)) {
an2.bark();
}Read the full question →type MyPartial<T> = { [K in keyof T]?: T[K] };
type Result = MyPartial<{ readonly a: number; b: string }>;Read the full question →const arr = ["a", "b"] as const;\ntype X = typeof arr[number];Read the full question →type Distrib<T> = T extends never ? 1 : 2;
type NoDistrib<T> = [T] extends [never] ? 1 : 2;
type A = Distrib<never>;
type B = NoDistrib<never>;Read the full question →type IsTrue<T> = T extends true ? "yes" : "no";
type R = IsTrue<boolean>;Read the full question →interface Comparer<T> { compare(a: T, b: T): number }
declare let cmp: Comparer<{ name: string }>;
declare let cmpDog: Comparer<{ name: string; bark(): void }>;
cmp = cmpDog;Read the full question →type ToArray<T> = T extends unknown ? T[] : never;
type R = ToArray<string | number>;Read the full question →type IsString<T> = T extends string ? true : false;\ntype R = IsString<string | number>;Read the full question →function f(x: boolean) { return x ? 1 : "a"; }Read the full question →type T = Extract<"a" | "b", "b">;Read the full question →We keep the correct answer, the explanation and the scoring behind sign-in so the platform stays honest, which is why the answer options and the worked explanation for every TypeScript question stay behind a free account. Signing in is free and takes a few seconds.
44 distinct TypeScript topics are tagged across the library. These are the real topic labels stored on the questions, not a hand-written list.
…