Skip to content

Commit 99fb85d

Browse files
committed
sigh
1 parent 7edcf0e commit 99fb85d

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

packages/kit/src/core/sync/write_types/index.spec.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ const cwd = fileURLToPath(new URL('./test', import.meta.url));
1414

1515
/**
1616
* @param {string} dir
17-
* @param {import('types').Config} config
17+
* @param {(code: string) => string} [prepare_expected]
1818
*/
19-
async function run_test(dir, config = {}) {
19+
async function run_test(dir, prepare_expected = (code) => code) {
2020
rimraf(path.join(cwd, dir, '.svelte-kit'));
2121

22-
const initial = options(config, 'config');
22+
const initial = options({}, 'config');
2323

2424
initial.kit.files.assets = path.resolve(cwd, 'static');
2525
initial.kit.files.params = path.resolve(cwd, 'params');
@@ -56,7 +56,7 @@ async function run_test(dir, config = {}) {
5656
parser: 'typescript'
5757
});
5858
const err_msg = `Expected equal file contents for ${file} in ${dir}`;
59-
assert.fixture(actual, expected, err_msg);
59+
assert.fixture(actual, prepare_expected(expected), err_msg);
6060
}
6161
}
6262

@@ -81,7 +81,15 @@ test('Create $types for grouped layout and page', async () => {
8181
});
8282

8383
test('Create $types with params', async () => {
84-
await run_test('slugs');
84+
await run_test('slugs', (code) =>
85+
// For some reason, the order of the params differentiates between windows and mac/linux
86+
process.platform === 'win32'
87+
? code.replace(
88+
'rest?: string; slug?: string; optional?: string',
89+
'optional?: string; rest?: string; slug?: string'
90+
)
91+
: code
92+
);
8593
});
8694

8795
test('Create $types with params and required return types for layout', async () => {

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 & { optional?: string; rest?: string; slug?: string };
15+
type LayoutParams = RouteParams & { rest?: string; slug?: string; optional?: string };
1616
type LayoutParentData = EnsureDefined<{}>;
1717

1818
export type LayoutServerData = null;

0 commit comments

Comments
 (0)