Type Alias NotHas<T, U>

NotHas<T, U>: Has<T, U> extends false
    ? true
    : false

Checks if type T does not have the specified type U.

Type Parameters

  • T

    The type to check if it does not have the specified type U.

  • U

    The type to check if it is not in the type T.

import { assertType, NotHas } from "@std/testing/types";

assertType<NotHas<string | number, Date>>(true);
assertType<NotHas<string, number>>(true);
assertType<NotHas<number, any>>(true);

assertType<NotHas<string | number, string>>(false);
assertType<NotHas<any, number>>(false);