Type Alias IsExact<T, U>
IsExact <T, U>: ParametersAndReturnTypeMatches<FlatType<AnyToBrand<T>>, FlatType<AnyToBrand<U>>> extends true
? ParametersAndReturnTypeMatches<FlatType<DeepPrepareIsExact<T>>, FlatType<DeepPrepareIsExact<U>>> extends true
? true
: false
: false
? ParametersAndReturnTypeMatches<FlatType<DeepPrepareIsExact<T>>, FlatType<DeepPrepareIsExact<U>>> extends true
? true
: false
: false
Type Parameters
Example: Usage
import { assertType, IsExact } from "@std/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);
Checks if type
Texactly matches typeU.