Kind: Type
Source: src/utils/types.ts
Part of: Utils
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
Simplify<T> remaps the properties of T into a plain object type, which makes expanded type hints easier to read in editors. It can also convert an interface-shaped type into a type alias shape for assignability checks.
Definition
ts{ [KeyType in keyof T]: T[KeyType] } & {}
Diagram
mermaidgraph LR A[Input type T] --> B[Simplify<T>] B --> C[Remapped object properties] C --> D[Clearer editor type hints] C --> E[Type alias assignability]
Usage
tstype Simplify<T> = {
[Key in keyof T]: T[Key];
};
interface User {
id: string;
name: string;
}
type UserRecord = Simplify<User>;
const user: UserRecord = {
id: "user_123",
name: "Ada",
};
AI Coding Instructions
- Apply
Simplify<T>when an intersection or mapped type produces hard-to-read editor hints. - Keep
Simplifytype-only; it does not transform values at runtime. - Use it near public type boundaries where consumers benefit from a remapped object shape.
- Do not expect
Simplify<T>to change property values, optionality, or readonly modifiers.
Was this page helpful?