Package: effect
Module: Types
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")
Signature
type NoInfer<A> = [A][A extends any ? 0 : never]
Since v2.0.0