Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type information for mousemove event #229

Merged
merged 3 commits into from
Aug 26, 2024

Conversation

rgieseke
Copy link
Contributor

This adds type information for the mousemove event in the Quadtree components. The error was:

src/_components/QuadTree.html.svelte:32:20
Error: Parameter 'evt' implicitly has an 'any' type. (js)

	function findItem(evt) {
		e = evt;
--
src/_components/QuadTree.percent-range.html.svelte:32:20
Error: Parameter 'evt' implicitly has an 'any' type. (js)

	function findItem(evt) {
		e = evt;

This also adds a JSDoc typecast for the 'layerX'/'layerY' values which probably is an example of those type annotations you didn't like so much (and me neither).
I didn't find another way to let the checking accept the uppercase conversion in layer${x.toUpperCase() as a type of 'layerX'|'layerY'.

rgieseke and others added 2 commits August 26, 2024 14:39

const xLayerKey = /** @type {'layerX'|'layerY'} */ (`layer${x.toUpperCase()}`);
const yLayerKey = /** @type {'layerX'|'layerY'}*/ (`layer${y.toUpperCase()}`);
console.log(evt.x, evt.y);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to remove this log

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooop, sory! Thanks for the merge!

@mhkeller
Copy link
Owner

That makes sense. Ya I tend to find those inline types harder for newcomers to read but seems like this is the best solution.

@mhkeller mhkeller merged commit fa94719 into mhkeller:ts-fixes Aug 26, 2024
@rgieseke rgieseke deleted the typescript-fixes-mouseevent branch August 26, 2024 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants