Skip to content
NoInfer

    ↑↓ move · ⏎ open · esc close

    Functions

    NoInfer

    Uses a type without letting that position contribute inference candidates.

    What it is

    An intrinsic inference brake. `NoInfer<T>` is the same type as `T` after inference, but while a generic call is being solved that position is checked against the result instead of helping choose it. This lets one argument be authoritative and another merely be validated.

    Examples

    • typeof selected
      "red" | "green"
    • NoInfer<1 | 2>
      2 | 1

      Outside inference it is exactly the wrapped type; it does not narrow, widen, or brand it.

    • NoInfer<string>
      string

    Each resolved type above was printed by TypeScript 6.0.3, not written by hand.

    What it does not do

    • It does not disable inference for the whole generic parameter. Other unwrapped positions still contribute candidates normally.
    • It is not a cast and does not make an invalid value legal. The blocked position is checked more strictly against the type inferred elsewhere.

    Takeaway

    Use `NoInfer` when one argument should determine a generic and another should only prove that it belongs to the result.