-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] better type generation for load functions with different return…
… values (#7425) * [fix] better type generation for load functions with different return values Fixes #7408 Also reworking write_types tests to type-check the outcome, not compare the generated code * explanation comment * fix excludes
- Loading branch information
1 parent
934db68
commit edd815e
Showing
39 changed files
with
223 additions
and
688 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
[fix] better type generation for load functions with different return values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/kit/src/core/sync/write_types/test/layout-advanced/(main)/+page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
// test to see if layout adjusts correctly if +page.js exists, but no load function | ||
|
||
/** @type {import('../.svelte-kit/types/src/core/sync/write_types/test/layout-advanced/(main)/$types').PageData} */ | ||
const data = { | ||
root: '' | ||
}; | ||
data.root; | ||
// @ts-expect-error | ||
data.main; |
18 changes: 17 additions & 1 deletion
18
packages/kit/src/core/sync/write_types/test/layout-advanced/(main)/sub/+page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
export function load() { | ||
/** @type {import('../../.svelte-kit/types/src/core/sync/write_types/test/layout-advanced/(main)/sub/$types').PageLoad} */ | ||
export async function load({ parent }) { | ||
const p = await parent(); | ||
p.main; | ||
p.root; | ||
// @ts-expect-error | ||
p.sub; | ||
return { | ||
sub: 'sub' | ||
}; | ||
} | ||
|
||
/** @type {import('../../.svelte-kit/types/src/core/sync/write_types/test/layout-advanced/(main)/sub/$types').PageData} */ | ||
const data = { | ||
main: '', | ||
root: '', | ||
sub: '' | ||
}; | ||
data.main; | ||
data.root; | ||
data.sub; |
35 changes: 0 additions & 35 deletions
35
packages/kit/src/core/sync/write_types/test/layout-advanced/_expected/$types.d.ts
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
packages/kit/src/core/sync/write_types/test/layout-advanced/_expected/(main)/$types.d.ts
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
packages/kit/src/core/sync/write_types/test/layout-advanced/_expected/(main)/sub/$types.d.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/kit/src/core/sync/write_types/test/layout/+layout.server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 13 additions & 1 deletion
14
packages/kit/src/core/sync/write_types/test/layout/+page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
export function load() { | ||
/** @type {import('./.svelte-kit/types/src/core/sync/write_types/test/layout/$types').PageLoad} */ | ||
export function load({ data }) { | ||
data.pageServer; | ||
// @ts-expect-error | ||
data.pageShared; | ||
return { | ||
pageShared: 'pageShared' | ||
}; | ||
} | ||
|
||
/** @type {import('./.svelte-kit/types/src/core/sync/write_types/test/layout/$types').PageData} */ | ||
const data = { | ||
shared: 'asd', | ||
pageShared: 'asd' | ||
}; | ||
data.shared; | ||
data.pageShared; |
Oops, something went wrong.