Skip to main content

NormalizeParam

Produces a Param type from a supplied string literal type or Param type. This utility type is a counterpart to the normalizeParam function.

This type is useful for implementing custom parameters where one of the inputs is another parameter that can also be expressed as a string. An example is the optional parameters implemented by @snout/router-path-extras.

import { NormalizeParam, Param } from "@snout/router-path";

type ParamA = Param<"a", number>;

type NormalizedA = NormalizeParam<ParamA>; // NormalizedA is Param<"a", number>
type NormalizedB = NormalizeParam<"b">; // NormalizedB is Param<"b", string>