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

PropUtils type checking not working properly in SvelteKit dev mode with few routes #115

Closed
vatro opened this issue Jul 2, 2022 · 0 comments
Assignees
Labels
bug Something isn't working code quality
Milestone

Comments

@vatro
Copy link
Owner

vatro commented Jul 2, 2022

I ran into this strange issue while refactoring test scenes, where type checking via PropUtils is not working in dev mode if there are only few routes (one-two links to scenes as a part of a side navigation) pointing to sveltehree-scenes. E.g. with:

public static isVector3(p: any): boolean {
return p?.constructor === Vector3
}

p?.constructor === Vector3 would be false.

If there are more routes, everything is ok in dev mode.
Also, with a built project, everything is ok in preview mode.

I'm not sure why this is happening, I guess it has something to do with the SvelteKit router / hmr in dev mode.
Changing the above to p?.constructor.name === "Vector3" works as a ducktape-fix.

After finding out what's going on, I've realized that I could generally improve type checking in PropUtils a bit by:

@vatro vatro self-assigned this Jul 2, 2022
@vatro vatro added bug Something isn't working code quality labels Jul 2, 2022
@vatro vatro added this to the 1.0.0-next.1 milestone Jul 2, 2022
vatro pushed a commit that referenced this issue Jul 2, 2022
- ducktape-fix
- use `Array.isArray() `
- refactor / add new methods to avoid redundant Array tcpe checks
- removed `isPropType` method since it's not being used anywhere.
vatro pushed a commit that referenced this issue Jul 2, 2022
vatro pushed a commit that referenced this issue Jul 2, 2022
vatro pushed a commit that referenced this issue Jul 2, 2022
@vatro vatro closed this as completed in 4776313 Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working code quality
Projects
None yet
Development

No branches or pull requests

1 participant