mhkeller / layercake

graphics framework for sveltejs
https://layercake.graphics
MIT License
1.36k stars 31 forks source link

Fix TypeScript errors from missing undefined or unprecise arrays #223

Closed rgieseke closed 2 months ago

rgieseke commented 2 months ago

Some time on a train, so here comes another TypeScript error message fix, basically I added |undefined to the type information whenever undefined is actually set.

This also how it's done in Svelte components itself, so I'm quite confident that that is reasonable.

/** @type {import('./types').MessageDetails | undefined} */
export let details = undefined;

/** @type {string | undefined} */
export let filename = undefined;

https://github.com/sveltejs/svelte/blob/33e44ea697356ea3f21fc6649919cf7fb4948b22/sites/svelte-5-preview/src/lib/Message.svelte#L8

I also turned some arrays into arrays of objects.

mhkeller commented 2 months ago

Great. I made some adjustments to the docs so the changes are reflected there, too. For data and flatData, I made those Array<any> since you could have arrays of arrays like in a stacked data structure.

mhkeller commented 2 months ago

Let me know how this looks / if this is done. I'll put it through as a patch release since it improves the types on the LayerCake component itself.

rgieseke commented 2 months ago

Wicked, thank you. Looks good to me! Is there a script to update the docs (or way to check they match)?

mhkeller commented 2 months ago

Nope I don't have anything automated. Also what's not automated are the components in the REPL since I don't think there's any way to programmatically access svelte REPLs.