Utilização

Type values passed between routes.

tsx
// Type values passed between routes.
import type { ParamValue, RouteParams } from 'kuito';

// Builds the query part of a share link from a route's params.
function query(params: RouteParams): string {
  const pairs = Object.entries(params).map(
    ([name, value]: [string, ParamValue]) =>
      `${encodeURIComponent(name)}=${encodeURIComponent(String(value))}`,
  );

  return pairs.length ? `?${pairs.join('&')}` : '';
}

query({ id: 42, autoplay: true }); // '?id=42&autoplay=true'

Declaração do tipo

ts
export type ParamValue = string | number | boolean;

Tipo

ts
string | number | boolean
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.