Skip to content

Commit

Permalink
Fix type declaration when using default value #271
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-hiller committed Nov 29, 2023
1 parent c607b3d commit 5e6fd98
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions library/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to the library will be documented in this file.

- Add support for boolean to `notValue` validation (pull request #261)
- Fix `RecordInput` and `RecordOuput` type when using `unionAsync` as key
- Fix output type for `nullable`, `nullableAsync`, `nullish`, `nullishAsync`, `optional` and `optionalAsync` when using a default value (issue #271)

## v0.21.0 (November 19, 2023)

Expand Down
4 changes: 2 additions & 2 deletions library/src/schemas/nullable/nullable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ export function nullable<TWrapped extends BaseSchema>(
*/
export function nullable<
TWrapped extends BaseSchema,
const TDefault extends
TDefault extends
| Input<TWrapped>
| (() => Input<TWrapped> | undefined)
| undefined
>(wrapped: TWrapped, default_: TDefault): NullableSchema<TWrapped, TDefault>;

export function nullable<
TWrapped extends BaseSchema,
const TDefault extends
TDefault extends
| Input<TWrapped>
| (() => Input<TWrapped> | undefined)
| undefined = undefined
Expand Down
4 changes: 2 additions & 2 deletions library/src/schemas/nullable/nullableAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function nullableAsync<TWrapped extends BaseSchema | BaseSchemaAsync>(
*/
export function nullableAsync<
TWrapped extends BaseSchema | BaseSchemaAsync,
const TDefault extends
TDefault extends
| Input<TWrapped>
| (() => Input<TWrapped> | Promise<Input<TWrapped> | undefined> | undefined)
| undefined
Expand All @@ -66,7 +66,7 @@ export function nullableAsync<

export function nullableAsync<
TWrapped extends BaseSchema | BaseSchemaAsync,
const TDefault extends
TDefault extends
| Input<TWrapped>
| (() => Input<TWrapped> | Promise<Input<TWrapped> | undefined> | undefined)
| undefined = undefined
Expand Down
4 changes: 2 additions & 2 deletions library/src/schemas/nullish/nullish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ export function nullish<TWrapped extends BaseSchema>(
*/
export function nullish<
TWrapped extends BaseSchema,
const TDefault extends
TDefault extends
| Input<TWrapped>
| (() => Input<TWrapped> | undefined)
| undefined
>(wrapped: TWrapped, default_: TDefault): NullishSchema<TWrapped, TDefault>;

export function nullish<
TWrapped extends BaseSchema,
const TDefault extends
TDefault extends
| Input<TWrapped>
| (() => Input<TWrapped> | undefined)
| undefined = undefined
Expand Down
4 changes: 2 additions & 2 deletions library/src/schemas/nullish/nullishAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function nullishAsync<TWrapped extends BaseSchema | BaseSchemaAsync>(
*/
export function nullishAsync<
TWrapped extends BaseSchema | BaseSchemaAsync,
const TDefault extends
TDefault extends
| Input<TWrapped>
| (() => Input<TWrapped> | Promise<Input<TWrapped> | undefined> | undefined)
| undefined
Expand All @@ -66,7 +66,7 @@ export function nullishAsync<

export function nullishAsync<
TWrapped extends BaseSchema | BaseSchemaAsync,
const TDefault extends
TDefault extends
| Input<TWrapped>
| (() => Input<TWrapped> | Promise<Input<TWrapped> | undefined> | undefined)
| undefined = undefined
Expand Down
4 changes: 2 additions & 2 deletions library/src/schemas/optional/optional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ export function optional<TWrapped extends BaseSchema>(
*/
export function optional<
TWrapped extends BaseSchema,
const TDefault extends
TDefault extends
| Input<TWrapped>
| (() => Input<TWrapped> | undefined)
| undefined
>(wrapped: TWrapped, default_: TDefault): OptionalSchema<TWrapped, TDefault>;

export function optional<
TWrapped extends BaseSchema,
const TDefault extends
TDefault extends
| Input<TWrapped>
| (() => Input<TWrapped> | undefined)
| undefined = undefined
Expand Down
4 changes: 2 additions & 2 deletions library/src/schemas/optional/optionalAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function optionalAsync<TWrapped extends BaseSchema | BaseSchemaAsync>(
*/
export function optionalAsync<
TWrapped extends BaseSchema | BaseSchemaAsync,
const TDefault extends
TDefault extends
| Input<TWrapped>
| (() => Input<TWrapped> | Promise<Input<TWrapped> | undefined> | undefined)
| undefined
Expand All @@ -66,7 +66,7 @@ export function optionalAsync<

export function optionalAsync<
TWrapped extends BaseSchema | BaseSchemaAsync,
const TDefault extends
TDefault extends
| Input<TWrapped>
| (() => Input<TWrapped> | Promise<Input<TWrapped> | undefined> | undefined)
| undefined = undefined
Expand Down

0 comments on commit 5e6fd98

Please sign in to comment.