1 | import { BasePredicate } from '..';
|
2 | export interface Shape {
|
3 | [key: string]: BasePredicate | Shape;
|
4 | }
|
5 | /**
|
6 | Extracts a regular type from a shape definition.
|
7 |
|
8 | @example
|
9 | ```
|
10 | const myShape = {
|
11 | foo: ow.string,
|
12 | bar: {
|
13 | baz: ow.boolean
|
14 | }
|
15 | }
|
16 |
|
17 | type X = TypeOfShape<typeof myShape> // {foo: string; bar: {baz: boolean}}
|
18 | ```
|
19 |
|
20 | This is used in the `ow.object.partialShape(…)` and `ow.object.exactShape(…)` functions.
|
21 | */
|
22 | export declare type TypeOfShape<S extends BasePredicate | Shape> = S extends BasePredicate<infer X> ? X : S extends Shape ? {
|
23 | [K in keyof S]: TypeOfShape<S[K]>;
|
24 | } : never;
|
25 | /**
|
26 | Test if the `object` matches the `shape` partially.
|
27 |
|
28 | @hidden
|
29 |
|
30 | @param object - Object to test against the provided shape.
|
31 | @param shape - Shape to test the object against.
|
32 | @param parent - Name of the parent property.
|
33 | */
|
34 | export declare function partial(object: Record<string, any>, shape: Shape, parent?: string): boolean | string;
|
35 | /**
|
36 | Test if the `object` matches the `shape` exactly.
|
37 |
|
38 | @hidden
|
39 |
|
40 | @param object - Object to test against the provided shape.
|
41 | @param shape - Shape to test the object against.
|
42 | @param parent - Name of the parent property.
|
43 | */
|
44 | export declare function exact(object: Record<string, any>, shape: Shape, parent?: string, isArray?: boolean): boolean | string;
|