$app/types
此模块包含你应用中路由的生成类型。
¥This module contains generated types for the routes in your app.
自 2.26 起可用
¥Available since 2.26
import type { type RouteId = stringA union of all the route IDs in your app. Used for page.route.id and event.route.id.
RouteId, type RouteParams<T extends RouteId> = T extends string ? Record<string, string> : Record<string, never>A utility for getting the parameters associated with a given route.
RouteParams, type LayoutParams<T extends RouteId> = T extends string ? Record<string, string> : Record<string, never>A utility for getting the parameters associated with a given layout, which is similar to RouteParams but also includes optional parameters for any child route.
LayoutParams } from '$app/types';资源(Asset)
¥Asset
static 目录中包含的所有资源文件名的并集,以及一个用于从 import 声明生成的资源路径的 string 通配符。
¥A union of all the filenames of assets contained in your static directory, plus a string wildcard for asset paths generated from import declarations.
type Asset = '/favicon.png' | '/robots.txt' | (string & {});RouteId
所有路由 ID 的联合应用。用于 page.route.id 和 event.route.id。
¥A union of all the route IDs in your app. Used for page.route.id and event.route.id.
type RouteId = '/' | '/my-route' | '/my-other-route/[param]';路径名(Pathname)
¥Pathname
应用中所有有效路径名的联合。
¥A union of all valid pathnames in your app.
type Pathname = '/' | '/my-route' | `/my-other-route/${string}` & {};ResolvedPathname
与 Pathname 类似,但可能带有 基本路径 前缀。用于 page.url.pathname。
¥Similar to Pathname, but possibly prefixed with a base path. Used for page.url.pathname.
type ResolvedPathname = `${'' | `/${string}`}/` | `${'' | `/${string}`}/my-route` | `${'' | `/${string}`}/my-other-route/${string}` | {};RouteParams
用于获取与给定路由关联的参数的实用程序。
¥A utility for getting the parameters associated with a given route.
type type BlogParams = RouteParams<"/blog/[slug]">BlogParams = RouteParams<'/blog/[slug]'>; // { slug: string }
type RouteParams<T extends RouteId> = { /* generated */ } | Record<string, never>;LayoutParams
用于获取与给定布局关联的参数的实用程序,类似于 RouteParams,但还包含任何子路由的可选参数。
¥A utility for getting the parameters associated with a given layout, which is similar to RouteParams but also includes optional parameters for any child route.
type RouteParams<T extends RouteId> = { /* generated */ } | Record<string, never>;