IsExact
import { IsExact } from "jsr:@ende/testing/types";type alias
type IsExact<T, U> = ParametersAndReturnTypeMatches<FlatType<AnyToBrand<T>>, FlatType<AnyToBrand<U>>> extends true ? ParametersAndReturnTypeMatches<FlatType<DeepPrepareIsExact<T>>, FlatType<DeepPrepareIsExact<U>>> extends true ? true : false : falseChecks if type T exactly matches type U.
Example: Usage
import { assertType, IsExact } from "@ende/testing/types";
assertType<IsExact<string | number, string | number>>(true);
assertType<IsExact<any, any>>(true); // ok to have any for both
assertType<IsExact<never, never>>(true);
assertType<IsExact<{ prop: string }, { prop: string }>>(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);