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

feat: Typing improvements to preload PR #7841

Merged
merged 12 commits into from
Nov 28, 2022

Conversation

elliott-with-the-longest-name-on-github
Copy link
Contributor

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 to data-sveltekit-blah without updating it everywhere it occurs, etc. The main improvement is just in the parsing and validation when we pull data-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.

@changeset-bot
Copy link

changeset-bot bot commented Nov 28, 2022

⚠️ No Changeset found

Latest commit: 8f42164

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Co-authored-by: gtmnayan <50981692+gtm-nayan@users.noreply.github.com>
@Rich-Harris Rich-Harris deleted the elliottjohnson-improve-data-sk-typings branch November 28, 2022 14:41
Rich-Harris added a commit that referenced this pull request Nov 28, 2022
…)` (#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>
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.

4 participants