Package: effect
Module: Types
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 }
Signature
type NoExcessProperties<T, U> = T & Readonly<Record<Exclude<keyof U, keyof T>, never>>
Since v3.9.0