Skip to content

Commit e2e52a3

Browse files
committed
add failing test
1 parent fcb4008 commit e2e52a3

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

packages/kit/src/core/sync/write_types/test/slugs/_expected/$types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type OutputDataShape<T> = MaybeWithVoid<
1212
Record<string, any>
1313
>;
1414
type EnsureDefined<T> = T extends null | undefined ? {} : T;
15-
type LayoutParams = RouteParams & { rest?: string; slug?: string };
15+
type LayoutParams = RouteParams & { rest?: string; slug?: string; optional?: string | void };
1616
type LayoutParentData = EnsureDefined<{}>;
1717

1818
export type LayoutServerData = null;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type * as Kit from '@sveltejs/kit';
2+
3+
type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
4+
type RouteParams = { optional: string | void }
5+
type MaybeWithVoid<T> = {} extends T ? T | void : T;
6+
export type RequiredKeys<T> = { [K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K; }[keyof T];
7+
type OutputDataShape<T> = MaybeWithVoid<Omit<App.PageData, RequiredKeys<T>> & Partial<Pick<App.PageData, keyof T & keyof App.PageData>> & Record<string, any>>
8+
type EnsureDefined<T> = T extends null | undefined ? {} : T;
9+
type PageParentData = EnsureDefined<import('../../$types.js').LayoutData>;
10+
11+
export type PageServerData = null;
12+
export type PageLoad<OutputData extends OutputDataShape<PageParentData> = OutputDataShape<PageParentData>> = Kit.Load<RouteParams, PageServerData, PageParentData, OutputData>;
13+
export type PageLoadEvent = Parameters<PageLoad>[0];
14+
export type PageData = Expand<Omit<PageParentData, keyof Kit.AwaitedProperties<Awaited<ReturnType<typeof import('../../../../../../x/[[optional]]/+page.js').load>>>> & EnsureDefined<Kit.AwaitedProperties<Awaited<ReturnType<typeof import('../../../../../../x/[[optional]]/+page.js').load>>>>>;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function load() {
2+
return { optional: 'optional' };
3+
}

packages/kit/src/core/sync/write_types/test/slugs/x/[[optional]]/+page.svelte

Whitespace-only changes.

0 commit comments

Comments
 (0)