Skip to content

Commit

Permalink
Move allowUndefinedInNonTupleArrays option example in the option do…
Browse files Browse the repository at this point in the history
…cumentation
  • Loading branch information
PicoI2 committed Dec 30, 2024
1 parent 90fd588 commit d7184be
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions source/partial-deep.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ export type PartialDeepOptions = {
Allows undefined values in non-tuple arrays. When set to `true`, elements of non-tuple arrays can be `undefined`. When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking. Defaults to `true` if not specified.
@default true
@example
You can prevent undefined values in non tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}` as the second type argument:
```
interface Settings {
languages: string[];
}
const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}> = {
languages: [undefined] // Error
languages: [] // OK
};
```
*/
readonly allowUndefinedInNonTupleArrays?: boolean;
};
Expand Down Expand Up @@ -60,20 +73,6 @@ const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
languages: [undefined]
};
```
You can prevent undefined values in non tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}` as the second type argument:
```
import type {PartialDeep} from 'type-fest';
interface Settings {
languages: string[];
}
const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}> = {
languages: [undefined] // Error
languages: [] // OK
};
```
@category Object
@category Array
Expand Down

0 comments on commit d7184be

Please sign in to comment.