Hyperlinkv0.8.0-beta.28

Types

Types.NoExcessPropertiestypeeffect/Types.ts:814
NoExcessProperties<T, U>

Constrains a type to prevent excess properties not present in T.

When to use

Use to catch accidental extra properties in generic functions at compile time.

Details

Extra keys from U that are not in T are mapped to never.

Example (Preventing extra properties)

import type { Types } from "effect"

type Expected = { a: number; b: string }
type Input = { a: number; b: string; c: boolean }

type Result = Types.NoExcessProperties<Expected, Input>
// { a: number; b: string; readonly c: never }
types
Source effect/Types.ts:8141 lines
export type NoExcessProperties<T, U> = T & Readonly<Record<Exclude<keyof U, keyof T>, never>>
Referenced by 1 symbols