-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Return non-null writable for defined defaultValue #87
Return non-null writable for defined defaultValue #87
Conversation
🦋 Changeset detectedLatest commit: 90fef99 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThe changes to Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
✅ Deploy Preview for sveltekit-search-params ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/lib/sveltekit-search-params.ts (4 hunks)
Additional comments not posted (7)
src/lib/sveltekit-search-params.ts (7)
136-143
: LGTM! The function is well-structured.The
primitiveEncodeAndDecodeOptions
function correctly handles encoding and decoding for primitive types and provides overloads for handling default values.
Line range hint
145-160
:
LGTM! The function is well-structured.The
objectEncodeAndDecodeOptions
function correctly handles encoding and decoding for objects and provides overloads for handling default values.
Line range hint
162-177
:
LGTM! The function is well-structured.The
arrayEncodeAndDecodeOptions
function correctly handles encoding and decoding for arrays and provides overloads for handling default values.
179-194
: LGTM! The function is well-structured.The
lzEncodeAndDecodeOptions
function correctly handles encoding and decoding using LZ compression and provides overloads for handling default values.
196-212
: LGTM! Thessp
object is well-defined.The
ssp
object correctly utilizes the newly defined encoding and decoding functions, enhancing modularity and type safety.
Line range hint
224-332
:
LGTM! The function maintains its functionality.The
queryParameters
function correctly handles query parameter management and maintains type safety.
333-336
: LGTM! The function overloads are well-defined.The
queryParam
function correctly handles the new overloads to ensure non-nullable types when a default value is provided.
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
78fd687
to
3591113
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- .changeset/poor-birds-dance.md (1 hunks)
- src/lib/sveltekit-search-params.ts (4 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/lib/sveltekit-search-params.ts
Additional comments not posted (1)
.changeset/poor-birds-dance.md (1)
1-5
: Changeset file looks good.The metadata and description accurately reflect the changes made in the
sveltekit-search-params
library.
Uh this is nice. I tried to do something like this for a long time and failed to do so. I will try to take a look today or tomorrow or else I will get to it on Monday, thanks for contributing |
Yeah, getting types right is a challenge. I wasn't feeling up to figuring out how to make It's a great library and it'll be nice to avoid casting my Please let me know if there's anything that I can do or clarify to help with your review process. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (3)
- .github/workflows/release.yml (1 hunks)
- .github/workflows/run-tests.yml (1 hunks)
- src/lib/sveltekit-search-params.ts (5 hunks)
Additional comments not posted (10)
.github/workflows/release.yml (2)
16-16
: Verify compatibility ofpnpm
version 9.The version has been updated from
8
to9
. Ensure that the new version is compatible with the workflow and doesn't introduce breaking changes.Verification successful
Verify compatibility of
pnpm
version 9.The version has been updated from
8
to9
. Ensure that the new version is compatible with the workflow and doesn't introduce breaking changes.
Verify compatibility of
pnpm
version 9.The version has been updated from
8
to9
. Ensure that the new version is compatible with the workflow and doesn't introduce breaking changes.
Verified compatibility of
pnpm
version 9.The update from version 8 to 9 does not introduce any breaking changes that would affect the workflow. The changes are mostly enhancements and bug fixes.
- Minor Changes: Support for specifying node version for running lifecycle scripts, and support for the
catalogs:
protocol.- Patch Changes: Enhancements to commands like
pnpm deploy
andpnpm outdated
, and bug fixes.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the compatibility of `pnpm` version 9. # Test: Check the release notes and documentation for breaking changes. gh release view 9 --repo pnpm/pnpm --json body | jq -r .bodyLength of output: 80
Script:
#!/bin/bash # Description: Verify the compatibility of `pnpm` version 9. # Step 1: List all releases to find the correct tag for version 9. gh release list --repo pnpm/pnpm # Step 2: Fetch the release notes for the correct tag. gh release view <correct-tag> --repo pnpm/pnpm --json body | jq -r .bodyLength of output: 1486
Script:
#!/bin/bash # Description: Verify the compatibility of `pnpm` version 9. # Fetch the release notes for the correct tag (v9.6.0). gh release view v9.6.0 --repo pnpm/pnpm --json body | jq -r .bodyLength of output: 8511
14-14
: Verify compatibility ofpnpm/action-setup@v4
.The version has been updated from
v2
tov4
. Ensure that the new version is compatible with the workflow and doesn't introduce breaking changes.Verification successful
Verify the existence of
pnpm/action-setup@v4
.The script did not find the release for
v4
. We need to verify ifv4
exists and check for any breaking changes.
Verify compatibility of
pnpm/action-setup@v4.0.0
.The version
v4.0.0
exists. We need to check the release notes for any breaking changes or important updates.
Verify compatibility of
pnpm/action-setup@v4.0.0
.The release notes indicate a breaking change: an error is thrown if one version of pnpm is specified in the
packageManager
field ofpackage.json
and a different version is specified in the action's settings. Verify the pnpm version specified inpackage.json
to ensure compatibility.
No issues found with
pnpm/action-setup@v4.0.0
.The
packageManager
field is not set inpackage.json
, so the breaking change mentioned in the release notes should not impact the workflow.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the compatibility of `pnpm/action-setup@v4`. # Test: Check the release notes and documentation for breaking changes. gh release view v4 --repo pnpm/action-setup --json body | jq -r .bodyLength of output: 89
Script:
#!/bin/bash # Description: List all available releases for `pnpm/action-setup`. # Test: Check the available releases. gh release list --repo pnpm/action-setupLength of output: 781
Script:
#!/bin/bash # Description: Verify the compatibility of `pnpm/action-setup@v4.0.0`. # Test: Check the release notes and documentation for breaking changes. gh release view v4.0.0 --repo pnpm/action-setup --json body | jq -r .bodyLength of output: 294
Script:
#!/bin/bash # Description: Verify the pnpm version specified in `package.json`. # Test: Check the `packageManager` field in `package.json` for the pnpm version. jq -r '.packageManager' package.jsonLength of output: 41
.github/workflows/run-tests.yml (3)
13-13
: Verify compatibility ofpnpm/action-setup@v4
.The version has been updated from
v2
tov4
. Ensure that the new version is compatible with the workflow and doesn't introduce breaking changes.
15-15
: Verify compatibility ofpnpm
version 9.The version has been updated from
8
to9
. Ensure that the new version is compatible with the workflow and doesn't introduce breaking changes.
18-18
: Verify compatibility of Node.js version 20.The version has been updated from
18
to20
. Ensure that the new version is compatible with the workflow and doesn't introduce breaking changes.src/lib/sveltekit-search-params.ts (5)
136-151
: LGTM!The
primitiveEncodeAndDecodeOptions
function correctly handles encoding and decoding for primitive types. The overloads are properly defined.
Line range hint
153-174
:
LGTM!The
objectEncodeAndDecodeOptions
function correctly handles encoding and decoding for objects. The overloads are properly defined.
Line range hint
176-197
:
LGTM!The
arrayEncodeAndDecodeOptions
function correctly handles encoding and decoding for arrays. The overloads are properly defined.
Line range hint
199-223
:
LGTM!The
lzEncodeAndDecodeOptions
function correctly handles encoding and decoding using LZ compression. The overloads are properly defined.
364-373
: LGTM!The
queryParam
function has been updated with new overloads to improve type safety and flexibility. The changes are properly defined and enhance the functionality.
Hey @gwax great work...i pushed a small fix for There's a typing problem with const store: Writable<LooseAutocomplete<{
str: unknown;
num: number;
bools: boolean;
obj: {
str: string;
};
arr: number[];
lz: string;
}>> this is the type that i'm getting back in const store = queryParameters({
str: true,
num: ssp.number(),
bools: ssp.boolean(),
obj: ssp.object<{ str: string }>(),
arr: ssp.array<number>(),
lz: ssp.lz<string>(),
}); in theory the expected type for this should be const store: Writable<LooseAutocomplete<{
str: string | null;
num: number | null;
bools: boolean | null;
obj: {
str: string;
} | null;
arr: number[] | null;
lz: string | null;
}>> and obviously passing an option with a default should also work there. I'll try to see if i can figure ths out |
Oh i'm actually an idiot: this was already like this in older versions...so no fault from you here sorry. Let me see if i can make something work. |
@gwax i actually did it (the types for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/lib/sveltekit-search-params.ts (10 hunks)
Additional comments not posted (7)
src/lib/sveltekit-search-params.ts (7)
146-161
: LGTM!The
primitiveEncodeAndDecodeOptions
function is well-implemented, providing clear and type-safe encoding and decoding options for primitive types.
Line range hint
163-184
:
LGTM!The
objectEncodeAndDecodeOptions
function is well-implemented, providing clear and type-safe encoding and decoding options for object types.
Line range hint
186-207
:
LGTM!The
arrayEncodeAndDecodeOptions
function is well-implemented, providing clear and type-safe encoding and decoding options for array types.
Line range hint
209-233
:
LGTM!The
lzEncodeAndDecodeOptions
function is well-implemented, providing clear and type-safe encoding and decoding options using LZ compression.
235-254
: LGTM!The updates to the
ssp
object improve readability and maintainability by centralizing the encoding and decoding logic.
Line range hint
264-363
:
LGTM!The updates to the
queryParameters
function align with the new encoding and decoding options and improve type safety.
376-385
: LGTM! But verify the function usage in the codebase.The updates to the
queryParam
function align with the objective of ensuring non-nullable return types when a default value is provided.However, ensure that all function calls to
queryParam
match the new signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- .changeset/poor-birds-dance.md (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- .changeset/poor-birds-dance.md
This change modifies the return type of queryParam to be Writable instead of Writable<T | null> if options is included and specifies a defaultValue.
We additionally modify the various ssp helper functions to return Writable instead of Writable<T | null> when a default value is provided.
Fixes #75
Summary by CodeRabbit
New Features
queryParam
function with new overloads for more flexible usage.Improvements
defaultValue
is provided, enhancing module reliability.