type-fns
Version:
A set of types, type checks, and type guards for simpler, safer, and easier to read code.
35 lines • 989 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
describe('PickOne', () => {
it('should constrain type correctly', async () => {
const findWrench = async ({}) => {
// ...
};
// you can find by metric
await findWrench({
size: {
metric: { millimeters: 16 },
},
});
// you can find by imperial
await findWrench({
size: {
imperial: { inches: '5/16' },
},
});
// you can't find by both
await findWrench({
// @ts-expect-error - cant be both
size: {
metric: { millimeters: 16 },
imperial: { inches: '5/16' },
},
});
// you can't find by neither
await findWrench({
// @ts-expect-error - cant be neither
size: {},
});
});
});
//# sourceMappingURL=PickOne.test.js.map