Hyperlinkv0.8.0-beta.28

Types

Types.NoInfertypeeffect/Types.ts:544
NoInfer<A>

Prevents TypeScript from inferring a type parameter from a specific position.

When to use

Use when a function parameter must match an inferred type without becoming an inference source.

Details

The parameter using NoInfer must still match the inferred type.

Example (Controlling inference)

import type { Types } from "effect"

declare function withDefault<T>(value: T, fallback: Types.NoInfer<T>): T

// T is inferred as "a" | "b" from the first argument only
const result = withDefault<"a" | "b">("a", "b")
models
Source effect/Types.ts:5441 lines
export type NoInfer<A> = [A][A extends any ? 0 : never]
Referenced by 159 symbols