Export Simplify type (#238)

This commit is contained in:
Ian Obermiller 2021-07-31 09:14:40 -04:00 committed by GitHub
parent 624c3313b7
commit 96f8d68df4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

1
base.d.ts vendored
View File

@ -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';

View File

@ -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
View File

@ -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]};