Skip to main content Link Search Menu Expand Document (external link)

ParamsOf overview

Type-level parameter extraction of the path-to-regexp syntax

Added in v1.0.0


Table of contents


utils

HasParams (type alias)

Signature

export type HasParams<T extends string> =
  A.Equals<T, string> extends 1
    ? false
    : [ParamsOf<T>] extends [infer R]
      ? [keyof R] extends [never]
        ? false
        : true
      : false

Added in v1.0.0

ParamsList (type alias)

ParamsList

Signature

export type ParamsList<T extends string> =
  A.Equals<T, string> extends 1
    ? [params?: {}]
    : [ParamsOf<T>] extends [infer R]
      ? [keyof R] extends [never]
        ? [params?: {}]
        : [params: R]
      : [params?: {}]

Added in v1.0.0

ParamsOf (type alias)

Extract the parameters from a path

Signature

export type ParamsOf<T extends string> = A.Equals<T, string> extends 1 ? {} : ToParams<ParseSegments<PathToSegments<T>>>

Added in v1.0.0