UNPKG

type-fns

Version:

A set of types, type checks, and type guards for simpler, safer, and easier to read code.

45 lines 1.7 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); describe('PickAny', () => { it('should constrain type correctly', () => __awaiter(void 0, void 0, void 0, function* () { const findFlowers = (input) => __awaiter(void 0, void 0, void 0, function* () { // ... }); // you can find by color yield findFlowers({ color: { petals: 'white', }, }); // you can find by size yield findFlowers({ size: { choice: 'LARGE', }, }); // you can find by both yield findFlowers({ color: { petals: 'white', }, size: { choice: 'LARGE', }, }); // you can't find by neither yield findFlowers({ // @ts-expect-error - cant be neither size: {}, }); })); }); //# sourceMappingURL=PickAny.test.js.map