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 type NoInfer<A> = [A][A extends any
? 0
: never]
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")
NoInfer<function (type parameter) A in type NoInfer<A>A> = [function (type parameter) A in type NoInfer<A>A][function (type parameter) A in type NoInfer<A>A extends any ? 0 : never]Referenced by 159 symbols
Array.bindArray.countByArray.dropWhileArray.dropWhileFilterArray.everyArray.filterArray.filterMapArray.findFirstArray.findFirstIndexArray.findFirstWithIndexArray.findLastArray.findLastIndexArray.partitionArray.someArray.spanArray.splitWhereArray.takeWhileArray.takeWhileFilterCause.mapChannel.catchReasonChannel.catchReasonsChannel.concatWithChannel.filterArrayChannel.filterArrayEffectChannel.filterMapArrayChannel.filterMapArrayEffectChannel.mapAccumChannel.onFirstChannel.orElseIfEmptyChannel.repeatChannel.retryChannel.scanChannel.scanEffectChannel.scheduleChannel.tapChunk.ChunkChunk.dropWhileChunk.everyChunk.filterChunk.findFirst+119 more