From 58bdb88cfc00add54ba84ba66957347f8397353a Mon Sep 17 00:00:00 2001 From: Eric Taylor Date: Wed, 1 Sep 2021 11:19:58 -0600 Subject: [PATCH] feat: add RouteProps type and export types from index --- src/index.ts | 3 +++ src/types.ts | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/index.ts b/src/index.ts index 8d63116..0f5e2ae 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,3 +15,6 @@ export { createBrowserRouter } from './utils/createBrowserRouter'; export { createHashRouter } from './utils/createHashRouter'; export { createMemoryRouter } from './utils/createMemoryRouter'; export { SuspenseResource } from './utils/SuspenseResource'; + +// Types +export * from './types'; diff --git a/src/types.ts b/src/types.ts index 2fc56c5..04805e2 100644 --- a/src/types.ts +++ b/src/types.ts @@ -256,3 +256,22 @@ export interface PreparedRouteEntry { location: Path; props: PreparedRouteEntryProps; } + +/** + * This is the type your route components should extend from. + * + * @example + * ``` + * import type { RouteProps } from 'yarr'; + * + * export interface MyRouteComponentProps extends RouteProps<'/some/path/:id'> { + * preloaded: { + * query: () => Promise<{ id: string }>; + * }; + * } + * ``` + */ +export interface RouteProps + extends PreparedRouteEntryProps { + params: RouteParameters; +}