es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
18 lines • 551 B
TypeScript
//#region src/types/Simplify.d.ts
/**
* Flattens an intersection or mapped type into a single, readable object type.
*
* The result is equivalent for plain object types, but editors show the
* resolved shape (`{ a: 1; b: 2 }`) instead of `A & B`.
*
* @template T - The type to flatten.
*
* @example
* type A = { name: string };
* type B = { age: number };
* type User = Simplify<A & B>;
* // hover => { name: string; age: number } (instead of A & B)
*/
type Simplify<T> = { [K in keyof T]: T[K] } & {};
//#endregion
export { Simplify };