Skip to main content
Module

x/ts_toolbelt_unofficial/mod.ts>F.NoInfer

👷 TypeScript's largest type utility library, now on Deno
Latest
type alias F.NoInfer
import { type F } from "https://deno.land/x/ts_toolbelt_unofficial@1.1.0/mod.ts";
const { NoInfer } = F;

Explain to TS which function parameter has priority for generic inference

Examples

Example 1

import {F} from 'ts-toolbelt.ts'

const fn0 = <A extends any>(a0: A, a1: F.NoInfer<A>): A => {
 return {} as unknown as A // just for the example
}

const fn1 = <A extends any>(a0: F.NoInfer<A>, a1: A): A => {
 return {} as unknown as A // just for the example
}

const fn2 = <A extends any>(a0: F.NoInfer<A>, a1: F.NoInfer<A>): A => {
 return {} as unknown as A // just for the example
}

const test0 = fn0('b', 'a') // error: infer priority is `a0`
const test1 = fn1('b', 'a') // error: infer priority is `a1`
const test2 = fn2('b', 'a') // works: infer priority is `a0` | `a1`

Type Parameters

A extends any
definition: [A][A extends any ? 0 : never]