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

Value is nullable if default value is provided #75

Closed
olehmisar opened this issue Mar 7, 2024 · 1 comment · Fixed by #87
Closed

Value is nullable if default value is provided #75

olehmisar opened this issue Mar 7, 2024 · 1 comment · Fixed by #87

Comments

@olehmisar
Copy link

Describe the bug

image

type of page should be Writable<number>

Reproduction

<script>
  import { queryParam, ssp } from "sveltekit-search-params";

  $: page = queryParam("p", ssp.number());
</script>

Logs

No response

@paoloricciuti
Copy link
Owner

I've tried and failed to make this work...but if you can I'll enjoy this enhancement 😁

gwax added a commit to gwax/sveltekit-search-params that referenced this issue Jul 27, 2024
This change modifies the return type of queryParam to be
Writable<T> instead of Writable<T | null> if options is
included and specifies a defaultValue.

We additionally modify the various ssp helper functions
to return Writable<T> instead of Writable<T | null> when
a default value is provided.

Fixes paoloricciuti#75
gwax added a commit to gwax/sveltekit-search-params that referenced this issue Jul 27, 2024
This change modifies the return type of queryParam to be
Writable<T> instead of Writable<T | null> if options is
included and specifies a defaultValue.

We additionally modify the various ssp helper functions
to return Writable<T> instead of Writable<T | null> when
a default value is provided.

Fixes paoloricciuti#75
gwax added a commit to gwax/sveltekit-search-params that referenced this issue Jul 27, 2024
This change modifies the return type of queryParam to be
Writable<T> instead of Writable<T | null> if options is
included and specifies a defaultValue.

We additionally modify the various ssp helper functions
to return Writable<T> instead of Writable<T | null> when
a default value is provided.

Fixes paoloricciuti#75
paoloricciuti added a commit that referenced this issue Jul 28, 2024
* Return non-null writable for defined defaultValue

This change modifies the return type of queryParam to be
Writable<T> instead of Writable<T | null> if options is
included and specifies a defaultValue.

We additionally modify the various ssp helper functions
to return Writable<T> instead of Writable<T | null> when
a default value is provided.

Fixes #75

* fix: default to string when nothing is passed

* fix: queryParameters types

* fix: update changeset to `breaking`

---------

Co-authored-by: paoloricciuti <ricciutipaolo@gmail.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 a pull request may close this issue.

2 participants