UNPKG

object-shape-tester

Version:
26 lines (25 loc) 852 B
import { type ShapeDefinition } from './shape-specifiers.js'; export { shapeToDefaultValue } from './shape-to-default-value.js'; /** * Creates a {@link ShapeDefinition} from any input. This produces both a type and a default value. * This is the core of the `object-shape-tester` package; {@link ShapeDefinition} instances are used * for all of the shape checking. * * @category Main * @example * * ```ts * import {defineShape} from 'object-shape-tester'; * * const myShape = defineShape({ * a: '', * b: -1, * }); * * function doThing( * // using the generated type and default value * input: typeof myShape.runtimeType = myShape.defaultValue, * ) {} * ``` */ export declare function defineShape<Shape, IsReadonly extends boolean = false>(shape: Shape, isReadonly?: IsReadonly): ShapeDefinition<Shape, IsReadonly>;