Skip to content

Commit c5854a6

Browse files
committed
docs: 📝 document use-case of types with existing types. Showcase use with ReturnType
1 parent c201466 commit c5854a6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ A collection of helper TypeScript types to test other TypeScript types. This col
1818
- IsNonUndefined - Check if a type is not undefined
1919
- IsNullish - Check if a type is either undefined or null
2020
- IsNonNullish - Check if a type is neither undefined or null
21+
2122
## Installation
2223

2324
To install `ts-test-utils` with Bun, run the following command:
@@ -44,6 +45,19 @@ that a `false` return is expected, and that a match is not expected:
4445
type ResultRecord = Expect<Equals<{ id: number }, { id: string }>>
4546
```
4647

48+
You can combine these types with existing types. As an example,
49+
here is the 'Equals' type being used to check a functions return type:
50+
51+
```typescript
52+
function myFunction() {
53+
return {
54+
id: 1,
55+
name: 'Craig',
56+
}
57+
}
58+
type Result = Expect<Equals<ReturnType<typeof myFunction>, { id: number, name: string }>>
59+
```
60+
4761
## Development Installation
4862

4963
To install dependencies:

0 commit comments

Comments
 (0)