object-shape-tester
Version:
Test object properties and value types.
30 lines (29 loc) • 995 B
TypeScript
import { type ArrayElement, type AtLeastTuple } from '@augment-vir/common';
import { type TUnsafe } from '@sinclair/typebox';
import { type UnionToIntersection } from 'type-fest';
import { type ShapeInitType } from '../shape/shape.js';
/**
* Creates a shape that merges multiple objects together. Note that intersecting fixed properties
* with a `recordShape` (or other generic mapped object keys) is not supported and will break in
* many ways.
*
* @category Shape
* @example
*
* ```ts
* import {intersectShape, checkValidShape} from 'object-shape-tester';
*
* const myShape = intersectShape(
* {
* a: '',
* },
* {
* b: '',
* },
* );
*
* checkValidShape({a: 'hi', b: 'bye'}, myShape); // `true`
* checkValidShape({a: 'hi'}, myShape); // `false`
* ```
*/
export declare function intersectShape<T extends AtLeastTuple<object, 1>>(...inits: T): import("../shape/shape.js").Shape<TUnsafe<UnionToIntersection<ShapeInitType<ArrayElement<T>>>>>;