You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d7212b1
Browse filesBrowse the repository at this point in the historyBrowse files
With [`routing.typedRoutes`](../../reference/config.md#routing-typedroutes) on, each path must match one of your routes. Cast a path that TypeScript can't check, such as one from a webhook payload, with `as RouteUrl` from `void/routes`. The cast turns the check off for that path.
Copy file name to clipboardExpand all lines: docs/guide/type-safety.md
+11-6Lines changed: 11 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -247,17 +247,21 @@ export async function getPrerenderPaths(): Promise<PageParams<'/blog/:slug'>[]>
247
247
248
248
In custom SSR mode the function returns full path strings, so annotate it as `Promise<string[]>`. See [Edge Prerendering](./edge/prerendering.md#dynamic-pages-with-params) and [Static Site Generation](./ssg.md#per-page-overrides).
249
249
250
-
`revalidate({ paths })` and `routing.prerender`are lists of plain strings. Annotate the array with `satisfies RouteUrl[]` so each path has to match a route. The check applies when [`routing.typedRoutes`](../reference/config.md#routing-typedroutes) is on; otherwise `RouteUrl` is `string`:
250
+
`routing.prerender`is a list of plain strings. Annotate the array with `satisfies RouteUrl[]` so each path has to match a route. The check applies when [`routing.typedRoutes`](../reference/config.md#routing-typedroutes) is on; otherwise `RouteUrl` is `string`:
[`routing.typedRoutes`](../reference/config.md#routing-typedroutes) checks plain URL strings in `Link`'s `href`, `router.visit()`, `router.prefetch()`, `router.flush()`, `c.rewrite()`, `c.redirect()`, `connectEventStream()`, `connectLiveStream()`, and `useIslandForm()`'s `post()`, `put()`, `patch()`, `delete()`, and `submit()`. Apps created with `void init` have it on. To turn it on in an existing app:
264
+
[`routing.typedRoutes`](../reference/config.md#routing-typedroutes) checks plain URL strings in `Link`'s `href`, `router.visit()`, `router.prefetch()`, `router.flush()`, `c.rewrite()`, `c.redirect()`, `revalidate({ paths })`, `connectEventStream()`, `connectLiveStream()`, and `useIslandForm()`'s `post()`, `put()`, `patch()`, `delete()`, and `submit()`. Apps created with `void init` have it on. To turn it on in an existing app:
261
265
262
266
```ts
263
267
// void.config.ts
@@ -346,10 +350,10 @@ The cast turns the check off, so cast only URLs you trust. Check a URL from the
346
350
347
351
`void/routes` exports two types for these strings:
348
352
349
-
-`RouteUrl`: the URL of one of your routes. `routeUrl()` returns it, and `c.rewrite()`and `useIslandForm()` accept it. Annotate a prerender or revalidate path list with it.
353
+
-`RouteUrl`: the URL of one of your routes. `routeUrl()` returns it, and `c.rewrite()`, `useIslandForm()`, and `revalidate({ paths })` accept it. Annotate a `routing.prerender` list with it.
350
354
-`Href`: anything a link or `c.redirect()` can point to: a `RouteUrl`, a same-page query or hash, or an external URL.
351
355
352
-
Cast a string that TypeScript can't check, such as a path from your CMS or a file in `public/`. The cast skips the check, so a wrong path still compiles:
356
+
Cast a string that TypeScript can't check, such as a path from your CMS or a file in `public/`. The cast turns the check off for that string:
353
357
354
358
::: code-group
355
359
@@ -416,7 +420,8 @@ Route types update with the dev server. For CI or standalone typechecking, run `
416
420
|`useParams`| Page patterns and the names of the params they return |
417
421
|`c.req.param`| Page param names, when the result is annotated with `PageParams`|
418
422
|`getPrerenderPaths`| Page param names, when the return type is annotated with `PageParams`|
419
-
|`revalidate`|`paths`, and `routing.prerender`, when the array is annotated with `satisfies RouteUrl[]`|
423
+
|`revalidate`| With `routing.typedRoutes`, URL strings in `paths`|
424
+
|`routing.prerender`| Paths, when the array is annotated with `satisfies RouteUrl[]`|
`paths` is `string[]`. Annotate the array with `satisfies RouteUrl[]` so TypeScript checks each path when [`routing.typedRoutes`](../config.md#routing-typedroutes) is on.
112
+
With [`routing.typedRoutes`](../config.md#routing-typedroutes) on, each path in `paths`must match one of your routes; otherwise `RouteUrl`is `string`. Cast a path that TypeScript can't check with `as RouteUrl`. The cast turns the check off for that path.
114
113
115
114
**Signature:**
116
115
117
116
```ts
118
-
function revalidate(options: { paths?:string[]; all?:boolean }):Promise<void>;
117
+
function revalidate(options: { paths?:RouteUrl[]; all?:boolean }):Promise<void>;
Copy file name to clipboardExpand all lines: docs/reference/config.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -378,7 +378,7 @@ routing: {
378
378
379
379
#### `routing.typedRoutes`
380
380
381
-
Type-check URL strings against your app's routes in `Link`'s `href`, `router.visit()`, `router.prefetch()`, `router.flush()`, `c.rewrite()`, `c.redirect()`, `useIslandForm()`, `connectEventStream()`, and `connectLiveStream()`. Omitted or `false` means off; `void init` turns it on for new apps. It changes types only, not navigation at runtime. Link and router strings may also be same-page queries or hashes, or `http://`, `https://`, `mailto:`, and `tel:` URLs. `useIslandForm()`takes a route URL; `connectEventStream()` and `connectLiveStream()` also take `http://` and `https://` URLs. `c.redirect()` accepts those strings, a `URL`, or a destination object. An external `https://` literal needs no cast; cast a string TypeScript cannot check with `as Href`. `revalidate({ paths })` and `routing.prerender`stay plain strings until you annotate them. See [Checked URL strings](../guide/type-safety#checked-url-strings).
381
+
Type-check URL strings against your app's routes in `Link`'s `href`, `router.visit()`, `router.prefetch()`, `router.flush()`, `c.rewrite()`, `c.redirect()`, `useIslandForm()`, `revalidate({ paths })`, `connectEventStream()`, and `connectLiveStream()`. Omitted or `false` means off; `void init` turns it on for new apps. It changes types only, not navigation at runtime. Link and router strings may also be same-page queries or hashes, or `http://`, `https://`, `mailto:`, and `tel:` URLs. `useIslandForm()`and `revalidate({ paths })` take route URLs; `connectEventStream()` and `connectLiveStream()` also take `http://` and `https://` URLs. `c.redirect()` accepts those strings, a `URL`, or a destination object. An external `https://` literal needs no cast; cast a string TypeScript cannot check with `as Href`. `routing.prerender`takes plain strings unless you annotate them. See [Checked URL strings](../guide/type-safety#checked-url-strings).
0 commit comments