-
Hi, I was wondering if is intended behavoir that passing a SvelteMap or SvelteSet declared from server side in +page.server.ts to a +page.svelte makes it a normal Map (Set) but why TypeScript still tells me that the types of them are SvelteMap (SvelteSet) +page.server.ts import { SvelteMap } from 'svelte/reactivity';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async () => {
return {
sveltemap: new SvelteMap([
['one', 1],
['two', 2],
])
};
}; +page.svelte <script lang="ts">
import { SvelteMap } from 'svelte/reactivity';
let { data } = $props();
const { sveltemap } = data;
console.log('sveltemap from server',sveltemap);
console.log(
'sveltemap from client',
new SvelteMap([
['one', 1],
['two', 2],
]),
);
</script> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This question is probably more relevant in the SvelteKit repo, but SvelteKit uses devalue to serialize server-side |
Beta Was this translation helpful? Give feedback.
This question is probably more relevant in the SvelteKit repo, but SvelteKit uses devalue to serialize server-side
load
ed props, andSvelteMap
s andSvelteSet
s are probably coerced to their nonreactive counterparts during serialization. TypeScript probably has no idea that this happens, so it incorrectly infers the types. Read here for more info.