Closed unknownsoldier08 closed 8 months ago
Hi @unknownsoldier08 ,
I just released version 0.8.9
with better type hinting support for .json()
, please update to the latest version.
You should now get proper documentation in your editor.
A full example using typescript would look like this
<script lang="ts">
import { source } from 'sveltekit-sse';
const channel = source('/events').select('notification');
const notification = channel.json<{ content: string }>();
</script>
{$notification?.content}
And with error management
<script lang="ts">
import { source } from 'sveltekit-sse';
const channel = source('/events').select('notification');
const notification = channel.json<{ content: string }>(function onError({ previous, error }) {
console.error(error);
return previous;
});
</script>
{$notification?.content}
Let me know if this is what you're looking for.
That works, thank you!
Is there any example on how to correctly type the .json() method using TypeScript?