Skip to content

Commit 0bbeffa

Browse files
authored
JSDoc improvements (#100)
## **This PR**: - [X] Fixes some typos. - [X] Renames some type parameters to make their intentions more clear. - [X] Adds JSDocs to some of the newly added utilities.
1 parent 67b4188 commit 0bbeffa

File tree

4 files changed

+189
-99
lines changed

4 files changed

+189
-99
lines changed

src/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export interface PositiveExpectTypeOf<Actual> extends BaseExpectTypeOf<Actual, {
176176
* @example
177177
* <caption>check that properties exist</caption>
178178
* ```ts
179-
* const obj = {a: 1, b: ''}
179+
* const obj = { a: 1, b: '' }
180180
*
181181
* expectTypeOf(obj).toHaveProperty('a')
182182
*
@@ -395,7 +395,7 @@ export interface NegativeExpectTypeOf<Actual> extends BaseExpectTypeOf<Actual, {
395395
* @example
396396
* <caption>check that properties exist</caption>
397397
* ```ts
398-
* const obj = {a: 1, b: ''}
398+
* const obj = { a: 1, b: '' }
399399
*
400400
* expectTypeOf(obj).toHaveProperty('a')
401401
*
@@ -519,9 +519,9 @@ export interface BaseExpectTypeOf<Actual, Options extends {positive: boolean}> {
519519
* @returns `true`.
520520
*/
521521
toBeCallableWith: Options['positive'] extends true
522-
? <A extends OverloadParameters<Actual>>(
523-
...args: A
524-
) => ExpectTypeOf<OverloadsNarrowedByParameters<Actual, A>, Options>
522+
? <Args extends OverloadParameters<Actual>>(
523+
...args: Args
524+
) => ExpectTypeOf<OverloadsNarrowedByParameters<Actual, Args>, Options>
525525
: never
526526

527527
/**
@@ -542,7 +542,7 @@ export interface BaseExpectTypeOf<Actual, Options extends {positive: boolean}> {
542542
* @returns `true`.
543543
*/
544544
toBeConstructibleWith: Options['positive'] extends true
545-
? <A extends ConstructorOverloadParameters<Actual>>(...args: A) => true
545+
? <Args extends ConstructorOverloadParameters<Actual>>(...args: Args) => true
546546
: never
547547

548548
/**
@@ -854,12 +854,12 @@ export type _ExpectTypeOf = {
854854
* form of a reference or generic type parameter.
855855
*
856856
* @example
857-
* import {foo, bar} from '../foo'
858-
* import {expectTypeOf} from 'expect-type'
857+
* import { foo, bar } from '../foo'
858+
* import { expectTypeOf } from 'expect-type'
859859
*
860860
* test('foo types', () => {
861-
* // make sure `foo` has type {a: number}
862-
* expectTypeOf(foo).toMatchTypeOf({a: 1})
861+
* // make sure `foo` has type { a: number }
862+
* expectTypeOf(foo).toMatchTypeOf({ a: 1 })
863863
* expectTypeOf(foo).toHaveProperty('a').toBeNumber()
864864
*
865865
* // make sure `bar` is a function taking a string:

src/messages.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ export type PrintType<T> =
3333

3434
/**
3535
* Helper for showing end-user a hint why their type assertion is failing.
36-
* This swaps "leaf" types with a literal message about what the actual and expected types are.
37-
* Needs to check for Not<IsAny<Actual>> because otherwise LeafTypeOf<Actual> returns never, which extends everything 🤔
36+
* This swaps "leaf" types with a literal message about what the actual and
37+
* expected types are. Needs to check for `Not<IsAny<Actual>>` because
38+
* otherwise `LeafTypeOf<Actual>` returns `never`, which extends everything 🤔
3839
*/
3940
export type MismatchInfo<Actual, Expected> =
4041
And<[Extends<PrintType<Actual>, '...'>, Not<IsAny<Actual>>]> extends true
@@ -96,7 +97,8 @@ const expectNullable = Symbol('expectNullable')
9697
export type ExpectNullable<T> = {[expectNullable]: T; result: Not<StrictEqualUsingBranding<T, NonNullable<T>>>}
9798

9899
/**
99-
* Checks if the result of an expecter matches the specified options, and resolves to a fairly readable error messsage if not.
100+
* Checks if the result of an expecter matches the specified options, and
101+
* resolves to a fairly readable error message if not.
100102
*/
101103
export type Scolder<
102104
Expecter extends {result: boolean},

0 commit comments

Comments
 (0)