Skip to content

Commit fc6d6ca

Browse files
committed
Document strict route names
Closes #859
1 parent 0b3b521 commit fc6d6ca

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,20 @@ If you don't have Ziggy's NPM package installed, add the following to your `jsco
287287
}
288288
```
289289

290+
#### Strict route name type checking
291+
292+
By default, even when you generate type definitions to enable better autocompletion, Ziggy still allows passing any string to `route()`. You can optionally enable strict type checking of route names, so that calling `route()` with a route name Ziggy doensn't recognizes triggers a type error. To do so, extend Ziggy's `TypeConfig` interface and set `strictRouteNames` to `true`:
293+
294+
```ts
295+
declare module 'ziggy-js' {
296+
interface TypeConfig {
297+
strictRouteNames: true
298+
}
299+
}
300+
```
301+
302+
Place this declaration in a `.d.ts` type definition file somewhere in your project. Depending on your setup, you may need to add an `export {};` statement to the end of file so TypeScript can pick it up.
303+
290304
## JavaScript frameworks
291305

292306
> [!NOTE]

0 commit comments

Comments
 (0)