Skip to content

Commit

Permalink
Export Simplify type (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianobermiller authored Jul 31, 2021
1 parent 624c331 commit 96f8d68
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 20 additions & 0 deletions source/simplify.d.ts
Original file line number Diff line number Diff line change
@@ -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]};

0 comments on commit 96f8d68

Please sign in to comment.