router-core/type-safety

Enforce full type inference across TanStack Router routes without manual annotations.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/guillempuche/engranatge --skill router-core-type-safety-guillempuche
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: router-core/type-safety
Source: https://github.com/guillempuche/engranatge/tree/main/docs/repos/tanstack-router/packages/router-core/skills/router-core/type-safety
Command: npx skills add https://github.com/guillempuche/engranatge --skill router-core-type-safety-guillempuche

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Developers often waste time adding unnecessary type annotations, casts, and generic parameters to TanStack Router routes, which masks real type errors and slows TypeScript compilation.

Core Features & Use Cases

  • Automatic full type inference: Params, search params, context, and loader data flow through the route tree without manual typings.
  • Single Register declaration: Declaring the router instance once provides type safety for all exported hooks and components.
  • Narrowed hooks and links: Using from, strict:false, and related utilities to get precise types and improve IDE autocomplete.
  • Performance tricks: Object syntax for addChildren, avoiding unused inferred types, and as const satisfies patterns for fast type checking.
  • Code‑splitting support: getRouteApi enables lazy‑loaded routes without pulling the entire route config.

Quick Start

Use this skill to define a new TanStack Router route with proper registration and rely on automatic type inference without adding any explicit type annotations.

Frequently Asked Questions about router-core/type-safety

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I achieve full type inference in TanStack Router without manual type annotations?

Full type inference in TanStack Router is achieved by declaring a single Register module with the router instance. This automatically propagates params, search params, context, and loader data without requiring explicit manual type annotations.

Why does TypeScript slow down or show incorrect types for my TanStack Router routes?

TypeScript compilation slows down when developers add unnecessary generic parameters and type casts to TanStack Router routes. Using object syntax for addChildren and as const satisfies patterns optimizes TypeScript type checking performance.

What is the best way to narrow hook and link types in TanStack Router?

The best way to narrow hook and link types is using from and strict:false type utility patterns. These utilities provide precise route tree types and significantly improve IDE autocomplete performance.

How do I support code-splitting and lazy-loaded routes in TanStack Router?

Code-splitting is supported in TanStack Router by using getRouteApi for lazy-loaded routes. This enables route code-splitting without pulling the entire route configuration file into the main bundle.

Does TanStack Router require manual type casts for loader data and search params?

TanStack Router does not require manual type casts for loader data and search params. Declaring the router instance once in a Register module provides automatic full type inference across the entire route tree.

When should I not use manual type annotations for TanStack Router route definitions?

You should not use manual type annotations for TanStack Router route definitions when automatic type inference is available. Explicit casts and generic parameters mask real type errors and slow TypeScript compilation.