Skip to main content
Module

x/utilitypes/exclusive.ts>Exclusive

A collection of utility types for TypeScript
Latest
type alias Exclusive
import { type Exclusive } from "https://deno.land/x/utilitypes@v1.0.0-beta.4/exclusive.ts";

Returns a record type with exclusive properties.

Examples

Example 1

Exclusive<{ a: string }, { a: number }>
// ({ a: string } & { b?: undefined }) |
// ({ b: number } & { a?: undefined })

Type Parameters

T extends Record<PropertyKey, unknown>
U extends Record<PropertyKey, unknown>
definition: (T & [k in keyof U]?: U[k] extends Record<PropertyKey, unknown> ? T[k] extends Record<PropertyKey, unknown> ? Exclusive<U[k], T[k]> : T[k] : T[k] extends Record<PropertyKey, unknown> ? T[k] : T[k] extends Primitive | unknown[] ? T[k] : never) | (U & [k in keyof T]?: T[k] extends Record<PropertyKey, unknown> ? U[k] extends Record<PropertyKey, unknown> ? Exclusive<T[k], U[k]> : U[k] : U[k] extends Record<PropertyKey, unknown> ? U[k] : U[k] extends Primitive | unknown[] ? U[k] : never)