Skip to content
GitHub

MessageParams

type alias in meocord/common Since 4.1.0

type MessageParams<M> = M extends string
  ? Record<Placeholders<M>, string | number>
  : IsPlural<M> extends true
    ? { count: number } & Record<
        Exclude<Placeholders<M[keyof M & PluralCategory]>, 'count'>,
        string | number
      >
    : never

The params a catalog message takes: one per {name} placeholder, whose name is ASCII letters, digits or _, and count for a plural message.

Other text in braces, such as { and }, is the message's own, and {{ and }} are one brace each, so {{id}} shows {id} and takes no param. A translator's t(key, params) is checked against it, so a placeholder left out or misspelt fails to compile. Use it to type params you build before translating.

See also