Mapped Types
Definition: A way to create a new type based on an existing one by iterating over its keys.Use Case: type ReadOnly<T> = { readonly [P in keyof T]: T[P] };.Evaluator Tip: This is used to create "Utility Types." If you see an AI manually rewriting an interface to make every field optional, suggest using the built-in Partial<T> mapped type instead.</T></T>
Const Assertions (as const)
Definition: Tells the compiler to treat an object as deeply immutable and its properties as literal types rather than broad types (like string).Use Case: const ROUTES = { HOME: ‘/’ } as const; ensures ROUTES.HOME is specifically ‘/’, not just any string.Evaluator Tip: This is a “Senior” signature. It prevents accidental property overrides and provides perfect autocompletion for constant objects.
Recursive Types
Definition: A type that refers to itself, used for representing nested structures like trees, file systems, or JSON objects.Use Case: type TreeNode = { value: string; children?: TreeNode[] };.Evaluator Tip: If an AI uses any for a nested comment section or a sidebar menu, it’s a failure. A senior evaluator uses a Recursive Type to ensure safety at every depth.
Type Narrowing & infer
Definition: Narrowing is moving from a broad type to a specific one. infer allows you to “extract” a type from inside another (e.g., getting the return type of a function).Evaluator Concept: High-level assessments look for Discriminated Unions (using a common status string) rather than simple truthiness checks.
Template Literal Types
Definition: Types that use backticks to create specific string patterns (e.g., type Icon = \icon-${‘sm’