Has<A, Key>Checks whether an object type contains any of the specified keys.
When to use
Use to branch type-level logic when at least one key from a candidate key set exists on an object type.
Details
Returns true if at least one key from Key exists in A, false
otherwise.
Example (Checking key presence)
import type { Types } from "effect"
type Yes = Types.Has<{ a: number; b: string }, "a" | "c"> // true
type No = Types.Has<{ a: number }, "b" | "c"> // falsemodels
Source effect/Types.ts:3393 lines
export type type Has<A, Key extends string> = (
Key extends infer K
? K extends keyof A
? true
: never
: never
) extends never
? false
: true
Checks whether an object type contains any of the specified keys.
When to use
Use to branch type-level logic when at least one key from a candidate key set
exists on an object type.
Details
Returns true if at least one key from Key exists in A, false
otherwise.
Example (Checking key presence)
import type { Types } from "effect"
type Yes = Types.Has<{ a: number; b: string }, "a" | "c"> // true
type No = Types.Has<{ a: number }, "b" | "c"> // false
Has<function (type parameter) A in type Has<A, Key extends string>A, function (type parameter) Key in type Has<A, Key extends string>Key extends string> = (function (type parameter) Key in type Has<A, Key extends string>Key extends infer function (type parameter) KK ? function (type parameter) KK extends keyof function (type parameter) A in type Has<A, Key extends string>A ? true : never : never) extends never
? false
: true