Moving Route and RouteParams types to app-utils
MODIFY
packages/app-utils/index.d.ts
packages/app-utils/index.d.ts
@@ -7,5 +7,7 @@ export {
Page,
PageContext,
Query,
- Method
+ Method,
+ Route,
+ RouteParams
} from './src/types';

MODIFY
packages/app-utils/src/types/index.d.ts
packages/app-utils/src/types/index.d.ts
@@ -56,6 +56,14 @@ export interface RenderOptions {
dev: boolean; // TODO this is awkward
}
+export interface Route {
+ pattern: RegExp;
+ parts: Array<{
+ params: (match: RegExpExecArray) => RouteParams,
+ i: number
+ }>;
+}
+
export type RouteParams = Record<string, string | string[]>;
export interface PageComponentManifest {

MODIFY
packages/kit/src/ambient.d.ts
packages/kit/src/ambient.d.ts
-declare module "MANIFEST" {
- import { SvelteComponent } from "svelte";
+declare module 'MANIFEST' {
+ import { SvelteComponent } from 'svelte';
+ import { Route } from '@sveltejs/app-utils';
- export type Route = {
- pattern: RegExp;
- parts: {
- params: (match: RegExpExecArray) => Record<string, string>,
- i: number
- }[];
- };
-
- export const components: (() => SvelteComponent)[];
+ export const components: Array<() => SvelteComponent>;
export const routes: Route[];
export const layout: SvelteComponent;
export const ErrorComponent: SvelteComponent;
}
-declare module "ROOT" {
- import { SvelteComponent } from "svelte";
+declare module 'ROOT' {
+ import { SvelteComponent } from 'svelte';
type Constructor<T> = {
new (...args: any[]): T;
- }
+ };
const root: Constructor<SvelteComponent>;
export default root;

MODIFY
packages/kit/src/interfaces.ts
packages/kit/src/interfaces.ts
@@ -4,19 +4,6 @@ export interface SvelteAppConfig {
adapter: string;
}
-export interface Route {
- id: string;
- handlers: Array<{
- type: 'page' | 'route';
- file: string;
- }>;
- pattern: RegExp;
- test: (url: string) => boolean;
- exec: (url: string) => Record<string, string>;
- parts: string[];
- params: string[];
-};
-
export interface Template {
render: (data: Record<string, string>) => string;
stream: (req, res, data: Record<string, string | Promise<string>>) => void;

MODIFY
packages/kit/src/runtime/navigation/types.ts
packages/kit/src/runtime/navigation/types.ts
import { Page } from '@sveltejs/app-utils';
-export { Page, Query, PageContext } from '@sveltejs/app-utils';
+export { Page, Query, PageContext, Route, RouteParams } from '@sveltejs/app-utils';
export interface HydratedTarget {
redirect?: Redirect;
@@ -28,16 +28,6 @@ export interface ScrollPosition {
y: number;
}
-export type RouteParams = Record<string, string | string[]>;
-
-export interface Route {
- pattern: RegExp;
- parts: Array<{
- params: (match: RegExpExecArray) => RouteParams,
- i: number
- }>;
-}
-
export interface Target {
href: string;
route: Route;

Moving Route and RouteParams types to app-utils (#146)