import { tsst, the } from 'tsst-tycho'; import { Xor, Matches, TypesEqual, InstanceOf, Awaited, Flatten, Widen, DiscriminateUnion, Const } from '../src/type'; describe(`type`, () => { describe(`Xor`, () => { type Person = Xor; it(`the>`, () => { tsst(() => { the>(); }).expectToCompile(); }); it(`the<{ name: 's' }, Xor<{ name: 's' }>>`, () => { tsst(() => { the<{ name: 's' }, Person<{ name: 's' }>>(); }).expectToCompile(); }); it(`the>`, () => { tsst(() => { the>(); }).expectToCompile(); }); }); describe(`Matches`, () => { it(`the<'1', Matches<1, number>>`, () => { tsst(() => { the<'1', Matches<1, number>>(); }).expectToCompile(); }); it(`the<'1', Matches>`, () => { tsst(() => { the<'1', Matches>(); }).expectToCompile(); }); it(`the<'0', Matches>`, () => { tsst(() => { the<'0', Matches>(); }).expectToCompile(); }); }); describe(`TypesEqual`, () => { it(`the<'0', TypesEqual>`, () => { tsst(() => { the<'0', TypesEqual>(); }).expectToCompile(); }); it(`the<'1', TypesEqual>`, () => { tsst(() => { the<'1', TypesEqual>(); }).expectToCompile(); }); }); describe(`InstanceOf`, () => { it(`the<'1', InstanceOf<1, number>>`, () => { tsst(() => { the<'1', InstanceOf<1, number>>(); }).expectToCompile(); }); it(`the<'0', InstanceOf>`, () => { tsst(() => { the<'0', InstanceOf>(); }).expectToCompile(); }); it(`the<'0', InstanceOf>`, () => { tsst(() => { the<'0', InstanceOf>(); }).expectToCompile(); }); }); describe(`Awaited`, () => { it(`the<1, Awaited<1>>`, () => { tsst(() => { the<1, Awaited<1>>(); }).expectToCompile(); }); it(`the<1, Awaited>>`, () => { tsst(() => { the<1, Awaited>>(); }).expectToCompile(); }); it(`the<1, Awaited>>>`, () => { tsst(() => { the<1, Awaited>>>(); }).expectToCompile(); }); it(`the<1, Awaited<1 | Promise<1>>>`, () => { tsst(() => { the<1, Awaited<1 | Promise<1>>>(); }).expectToCompile(); }); }); describe(`Flatten`, () => { it(`the<1, Flatten<1>>`, () => { tsst(() => { the<1, Flatten<1>>(); }).expectToCompile(); }); it(`the<1, Flatten<[1, 1]>>`, () => { tsst(() => { the<1, Flatten<[1, 1]>>(); }).expectToCompile(); }); it(`the<1, Flatten<[1, [1]]>>`, () => { tsst(() => { the<1, Flatten<[1, [1]]>>(); }).expectToCompile(); }); }); describe(`Widen`, () => { it(`the, number>`, () => { tsst(() => { the, number>(); }).expectToCompile(); }); it(`the, boolean>`, () => { tsst(() => { the, boolean>(); }).expectToCompile(); }); it(`the, string>`, () => { tsst(() => { the, string>(); }).expectToCompile(); }); }); describe(`DiscriminateUnion`, () => { it(`the>`, () => { tsst(() => { interface Square { kind: "square"; size: number; } interface Rectangle { kind: "rectangle"; width: number; height: number; } interface Circle { kind: "circle"; radius: number; } type Shape = Square | Rectangle | Circle; type DiscriminateShape = DiscriminateUnion; the>(); }).expectToCompile(); }); }); describe(`Const`, () => { it(`the<1, Const<1, 2>>`, () => { tsst(() => { the<1, Const<1, 2>>(); }).expectToCompile(); }); }); // describe(``, () => { // it(``, () => { // tsst(() => { // the<, <>>(); // }).expectToCompile(); // }); // }); });