1 | import { IType, IAnyType, ExtractCSTWithSTN } from "../../internal";
|
2 |
|
3 | export declare type ValidOptionalValue = string | boolean | number | null | undefined;
|
4 |
|
5 | export declare type ValidOptionalValues = [ValidOptionalValue, ...ValidOptionalValue[]];
|
6 |
|
7 | export declare type OptionalDefaultValueOrFunction<IT extends IAnyType> = IT["CreationType"] | IT["SnapshotType"] | (() => ExtractCSTWithSTN<IT>);
|
8 | /** @hidden */
|
9 | export interface IOptionalIType<IT extends IAnyType, OptionalVals extends ValidOptionalValues> extends IType<IT["CreationType"] | OptionalVals[number], IT["SnapshotType"], IT["TypeWithoutSTN"]> {
|
10 | }
|
11 | export declare function optional<IT extends IAnyType>(type: IT, defaultValueOrFunction: OptionalDefaultValueOrFunction<IT>): IOptionalIType<IT, [undefined]>;
|
12 | export declare function optional<IT extends IAnyType, OptionalVals extends ValidOptionalValues>(type: IT, defaultValueOrFunction: OptionalDefaultValueOrFunction<IT>, optionalValues: OptionalVals): IOptionalIType<IT, OptionalVals>;
|
13 | /**
|
14 | * Returns if a value represents an optional type.
|
15 | *
|
16 | * @template IT
|
17 | * @param type
|
18 | * @returns
|
19 | */
|
20 | export declare function isOptionalType<IT extends IAnyType>(type: IT): type is IT;
|
21 |
|
\ | No newline at end of file |