-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
361b933
commit 0549e61
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,51 @@ | ||
# type-expand | ||
|
||
Utilities to expand TypeScript types shown by IntelliSense in Visual Studio Code. | ||
|
||
Inspired by https://stackoverflow.com/a/57683652. | ||
|
||
## Installation | ||
|
||
```shell | ||
npm install --save-dev type-expand | ||
``` | ||
|
||
## Usage | ||
|
||
Commented lines are the results shown in hover info when your cursor hovers over the types. | ||
|
||
```typescript | ||
import type { Expand, ExpandDeep } from "type-expand"; | ||
|
||
type FooError = { foo: Error }; | ||
type BarError = { bar: Error }; | ||
|
||
type FooBarError = FooError & BarError; | ||
// type FooBarError = FooError & BarError; | ||
|
||
type ExpandedFooBarError = Expand<FooBarError>; | ||
// type ExpandedFooBarError = { | ||
// foo: Error; | ||
// bar: Error; | ||
// }; | ||
|
||
type DeepExpandedFooBarError = ExpandDeep<FooBarError>; | ||
// type DeepExpandedFooBarError = { | ||
// foo: { | ||
// name: string; | ||
// message: string; | ||
// stack?: string; | ||
// }; | ||
// bar: { | ||
// name: string; | ||
// message: string; | ||
// stack?: string; | ||
// }; | ||
// }; | ||
``` | ||
|
||
Unlike other utility types, `Expand` and `ExpandDeep` do not transform type in any way. | ||
|
||
## See Also | ||
|
||
- [`typesafeconfig`](https://github.com/shian15810/typesafeconfig) |