TypeScript and Types
Types are most useful when they stay flexible. The recommended approach is to start wide, infer from runtime objects, and use assertions so you can keep moving without blocking the component router.
Key Ideas
- Use
anyby default so types never slow you down. - Prefer widened types so routes can accept more shapes.
- Derive types from runtime data to keep them aligned with real usage.
These ideas keep the type layer lightweight. A wide type surface lets file routes share data easily. Runtime‑derived types keep component routes aligned with the actual data flow. Assertions let you move fast without waiting on perfect type definitions.
any as a Default Strategy
export type RouteData = any;
Widen Types for Flexibility
export type UserLike = string | number | boolean | object;
Types Derived from Runtime Objects
const defaults = { mode: "warm", flags: {} };
export type Settings = typeof defaults;
Type Assertions Instead of Types
const payload = {} as { id: string; value: unknown };
Generics for Everything
export type Box<T> = { value: T };
Unified TS/JS in the Same Module
export const runtime = { enabled: true };
export type Runtime = typeof runtime;