import { Assert, AssertFalse, AssertTrue, assertType, Has, IsAny, IsExact, IsNever, IsNullable, IsUnknown, NotHas,} from "./types.ts";
{ assertType<IsNullable<string | null>>(true); assertType<IsNullable<string | undefined>>(true); assertType<IsNullable<null | undefined>>(true);
assertType<IsNullable<string>>(false); assertType<IsNullable<any>>(false); assertType<IsNullable<never>>(false); assertType<IsNullable<unknown>>(false);}
{ assertType<IsExact<string | number, string | number>>(true); assertType<IsExact<string | number | Date, string | number | Date>>(true); assertType<IsExact<string | undefined, string | undefined>>(true); assertType<IsExact<any, any>>(true); assertType<IsExact<unknown, unknown>>(true); assertType<IsExact<never, never>>(true); assertType<IsExact<{}, {}>>(true); assertType<IsExact<{ prop: string }, { prop: string }>>(true); assertType<IsExact<{ prop: { prop: string } }, { prop: { prop: string } }>>( true, ); assertType<IsExact<{ prop: never }, { prop: never }>>(true); assertType<IsExact<{ prop: any }, { prop: any }>>(true); assertType<IsExact<{ prop: unknown }, { prop: unknown }>>(true); assertType<IsExact<typeof globalThis, typeof globalThis>>(true);
assertType<IsExact<string | number | Date, string | number>>(false); assertType<IsExact<string, string | number>>(false); assertType<IsExact<string | undefined, string>>(false); assertType<IsExact<string | undefined, any | string>>(false); assertType<IsExact<any | string | undefined, string>>(false); assertType<IsExact<string, any>>(false); assertType<IsExact<string, unknown>>(false); assertType<IsExact<string, never>>(false); assertType<IsExact<never, never | string>>(false); assertType<IsExact<unknown, any>>(false); assertType<IsExact<never, any>>(false); assertType<IsExact<Date | typeof globalThis, Date>>(false); assertType<IsExact<{ name: string; other?: Date }, { name: string }>>(false); assertType<IsExact<{ prop: Date }, { prop: string }>>(false); assertType<IsExact<{ other?: Date }, { prop?: string }>>(false); assertType<IsExact<{ prop: { prop?: string } }, { prop: { prop: string } }>>( false, ); assertType<IsExact<{ prop: any }, { prop: string }>>(false); assertType<IsExact<{ prop: any }, { prop: unknown }>>(false); assertType<IsExact<{ prop: any }, { prop: never }>>(false); assertType<IsExact<{ prop: unknown }, { prop: never }>>(false); assertType<IsExact<{ prop: { prop: unknown } }, { prop: { prop: any } }>>( false, ); assertType<IsExact<{ prop: { prop: unknown } }, { prop: { prop: never } }>>( false, ); assertType<IsExact<{ prop: { prop: any } }, { prop: { prop: never } }>>( false, ); assertType<IsExact<{ prop: string }, { prop: never }>>(false); assertType<IsExact<{ prop: { prop: any } }, { prop: { prop: string } }>>( false, ); assertType< IsExact< { prop: any } | { prop: string }, { prop: number } | { prop: string } > >(false); assertType<IsExact<{ prop: string | undefined }, { prop?: string }>>(false); }
{ assertType<Has<string | number, string>>(true); assertType<Has<number, number>>(true); assertType<Has<string | number, Date | string>>(true); assertType<Has<any, number>>(true); assertType<Has<any, any>>(true); assertType<Has<any, unknown>>(true); assertType<Has<any, never>>(true);
assertType<Has<string | number, Date>>(false); assertType<Has<string, number>>(false); assertType<Has<number, any>>(false); assertType<Has<unknown, any>>(false); assertType<Has<never, any>>(false);}
{ assertType<NotHas<string | number, Date>>(true); assertType<NotHas<string, number>>(true);
assertType<NotHas<string | number, string>>(false); assertType<NotHas<number, number>>(false); assertType<NotHas<string | number, Date | string>>(false); }
{ assertType<IsAny<any>>(true);
assertType<IsAny<string>>(false); assertType<IsAny<unknown>>(false); assertType<IsAny<never>>(false);
assertType<IsExact<IsAny<string>, false>>(true); assertType<IsExact<IsAny<5>, false>>(true);}
{ assertType<IsNever<never>>(true);
assertType<IsNever<string>>(false); assertType<IsNever<any>>(false); assertType<IsNever<unknown>>(false);}
{ assertType<IsUnknown<unknown>>(true);
assertType<IsUnknown<string>>(false); assertType<IsUnknown<any>>(false); assertType<IsUnknown<never>>(false);}
{ type test = AssertTrue<IsNever<never>>;}
{ type test = AssertFalse<IsNever<string>>;}
{ type test = | Assert<Has<string | number, number>, true> | Assert<Has<string | number, Date>, false>;}
{ type RecursiveType1 = string | number | Date | RecursiveType1[]; assertType<IsExact<RecursiveType1, RecursiveType1>>(true); type RecursiveType2 = { a: string; prop: RecursiveType2; sub: { prop: RecursiveType2; other: RecursiveType1; }; }; assertType<IsExact<RecursiveType2, RecursiveType2>>(true); assertType<IsExact<RecursiveType1, RecursiveType2>>(false);}