kit
kit copied to clipboard
Typescript for +layout.svelte should not give ok to PageData
Describe the bug
I had misunderstood the docs and created a +page.ts and a +layout.svelte.
In the latter I had export let data: PageData;
which vsCode said was ok and would give me the data I expected. But the runtime does not pass data this way - you need +layout.ts to get data for +layout.svelte
Reproduction
create a +page.ts that returns {user: Promise.resolve(user)}
and a +layout.svelte with
export let data: PageData;
const user : User = data.user;
console.log(data.user)
line 2 is wrongly Oked by typescript
Logs
logs `undefined`
System Info
System:
OS: macOS 13.1
CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Memory: 28.33 MB / 8.00 GB
Shell: 5.8 - /usr/local/bin/zsh
Binaries:
Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
Browsers:
Chrome: 108.0.5359.124
Firefox: 104.0.2
Safari: 16.2
Safari Technology Preview: 16.4
npmPackages:
@sveltejs/adapter-auto: ^1.0.0 => 1.0.0
@sveltejs/kit: ^1.0.0 => 1.0.0
svelte: ^3.54.0 => 3.55.0
vite: ^4.0.0 => 4.0.1
Severity
serious, but I can work around it
Additional Information
No response