The first type to compare.
The second type to compare.
A boolean literal indicating whether T1 should match T2.
If you expect the types to match, set this to true; if not, set it to false.
This utility will return a boolean that is true if your expectation was correct, otherwise false.
type ResultType = TestType<Type1, Type2, true>;
TestType accepts three arguments: the types you're comparing (Type1 and Type2) and a boolean (true if you expected them to match, false otherwise). The resulting type will tell if your expectation is correct, true if it is, else false.
You can use it however you want, maybe to test a type on the go, or,
test using a testing framework. Here's an example with vitest
import type { Abs, TestType } from 'typyx';
import { test, expect , expectTypeOf} from 'vitest';
test('|-54| should be 54',() => {
type ShouldPass = true;
expectTypeOf<TestType<Abs<-54>, 54, true>>().toEqualTypeOf<ShouldPass>();
});
Determines if two types match.