mirror of
https://github.com/sindresorhus/type-fest.git
synced 2025-12-08 19:25:05 +00:00
Export Simplify type (#238)
This commit is contained in:
parent
624c3313b7
commit
96f8d68df4
1
base.d.ts
vendored
1
base.d.ts
vendored
@ -35,6 +35,7 @@ export {Entry} from './source/entry';
|
||||
export {Entries} from './source/entries';
|
||||
export {SetReturnType} from './source/set-return-type';
|
||||
export {Asyncify} from './source/asyncify';
|
||||
export {Simplify} from './source/simplify';
|
||||
|
||||
// Miscellaneous
|
||||
export {PackageJson} from './source/package-json';
|
||||
|
||||
@ -119,6 +119,7 @@ Click the type names for complete docs.
|
||||
- [`Entries`](source/entries.d.ts) - Create a type that represents the type of the entries of a collection.
|
||||
- [`SetReturnType`](source/set-return-type.d.ts) - Create a function type with a return type of your choice and the same parameters as the given function type.
|
||||
- [`Asyncify`](source/asyncify.d.ts) - Create an async version of the given function type.
|
||||
- [`Simplify`](source/simplify.d.ts) - Flatten the type output to improve type hints shown in editors.
|
||||
|
||||
### Template literal types
|
||||
|
||||
|
||||
20
source/simplify.d.ts
vendored
20
source/simplify.d.ts
vendored
@ -1,4 +1,24 @@
|
||||
/**
|
||||
Flatten the type output to improve type hints shown in editors.
|
||||
|
||||
@example
|
||||
```
|
||||
import {Simplify} from 'type-fest';
|
||||
|
||||
type PositionProps = {
|
||||
top: number;
|
||||
left: number;
|
||||
};
|
||||
|
||||
type SizeProps = {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
|
||||
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
||||
type Props = Simplify<PositionProps & SizeProps>;
|
||||
```
|
||||
|
||||
@category Utilities
|
||||
*/
|
||||
export type Simplify<T> = {[KeyType in keyof T]: T[KeyType]};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user