-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat: Typing improvements to preload PR #7841
Conversation
|
Co-authored-by: gtmnayan <50981692+gtm-nayan@users.noreply.github.com>
…)` (#7776) * rename prefetch -> preload and prefetchRoutes -> prepare, tweak prepare API * rename data-sveltekit-prefetch to data-sveltekit-preload * update migration guide * various * shuffle some things around * refactor a tiny bit * fix * implement data-sveltekit-prepare * make it slightly more self-contained * keyboard events * named constants * handle malformed URLs * rename * use data-sveltekit-preload-code and data-sveltekit-preload-data * rename stuff * fix * docs * missed a spot * changesets * clarification * fix migration guide * tidy up * feat: Typing improvements to preload PR (#7841) * feat: Improve typings on data-sveltekit attributes * feat: improved constants * Update packages/kit/src/runtime/client/utils.js Co-authored-by: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> * remove dev guard from validateAttributeValue * snake_case * dot notation * shorter name so prettier doesnt butcher the code * shorter name * get typechecking working * neaten * oops * tweak Co-authored-by: Rich Harris <richard.a.harris@gmail.com> Co-authored-by: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> Co-authored-by: Rich Harris <hello@rich-harris.dev> * Update documentation/docs/30-advanced/30-link-options.md * move up explanation of mobile behaviour * clarify * Update packages/kit/src/runtime/client/client.js Co-authored-by: S. Elliott Johnson <sejohnson@torchcloudconsulting.com> * change "page" to "eager" * make side-effecty * oops * fix docs Co-authored-by: S. Elliott Johnson <sejohnson@torchcloudconsulting.com> Co-authored-by: gtmnayan <50981692+gtm-nayan@users.noreply.github.com>
Please consider these changes as 100% a suggestion -- I figured this was easier than making some super-complex GitHub comment. This should be safe to merge into the branch without additional changes.
This more explicitly states what typings we're going for in this utils file. As with most situations where we provide stricter types, this just helps us not shoot ourselves in the foot later by somehow introducing
undefined
where we expect null, adding a new value todata-sveltekit-blah
without updating it everywhere it occurs, etc. The main improvement is just in the parsing and validation when we pulldata-sveltekit-{x}
values from DOM elements. Some mapped typing there ensures that we're both validating the value and that the data attribute we're trying to retrieve provides the values we want it to.