Skip to content

Commit

Permalink
feat: add RouteProps type and export types from index
Browse files Browse the repository at this point in the history
  • Loading branch information
erictaylor committed Sep 1, 2021
1 parent e0fbfef commit 58bdb88
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
19 changes: 19 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Path extends string>
extends PreparedRouteEntryProps {
params: RouteParameters<Path>;
}

0 comments on commit 58bdb88

Please sign in to comment.