-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
fix: #1005 fixed, by updating type-definations to getItem method. #1007
Conversation
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Maybe add a type test into the storage tests for that |
@Timeraa I am unsure, what do you mean? I have tested the project locally and after then I created a pull request. Some cases const value = await storage.getItem("local:key")
// ^? any const value = await storage.getItem<string>("local:key")
// ^? string | null const value = await storage.getItem("local:key", { fallback: "abc" })
// ^? string const value = await storage.getItem<string>("local:key", { fallback: "abc" })
// ^? string |
Using https://vitest.dev/guide/testing-types in https://github.com/wxt-dev/wxt/blob/main/packages/wxt/src/__tests__/storage.test.ts I think @aklinker1 needs to add the --typecheck flag to the test commands but you can use |
@Timeraa Hi, according to your guidance I rank the typecheck command and all the tests in storage.test.ts are passing and I am sure it's safe to merge. |
@aklinker1 or @Timeraa, please merge the pull request asap, I am unable to concentrate on my tomorrows' board examination or if you are not planning to merge please provide appropriate feedback. Thanks in advance. |
@wxt-dev/auto-icons
@wxt-dev/i18n
@wxt-dev/module-react
@wxt-dev/module-solid
@wxt-dev/module-svelte
@wxt-dev/module-vue
wxt
commit: |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1007 +/- ##
==========================================
- Coverage 82.14% 81.87% -0.28%
==========================================
Files 127 127
Lines 6625 6625
Branches 1103 1102 -1
==========================================
- Hits 5442 5424 -18
- Misses 1169 1187 +18
Partials 14 14 ☔ View full report in Codecov by Sentry. |
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.
Can you make the PR editable by maintainers? I can't seem to push the type tests.
it('should return a nullable type when getItem is called without a fallback', async () => {
const res = await storage.getItem<string>('local:test');
expectTypeOf(res).toBeNullable();
});
it('should return a nullable type when getItem is called without a fallback', async () => {
const res = await storage.getItem<string>('local:test', {
fallback: 'test',
});
expectTypeOf(res).not.toBeNullable();
});
@aklinker1 Hi, I have allowed edits by maintainers. |
@aklinker1 Hi, I think there is some problem with your test code. |
No, the test code is correct, your change doesn't work when the first type parameter is passed in. - const res = await storage.getItem<string>('local:test', {
+ const res = await storage.getItem('local:test', {
fallback: 'test',
}); |
@aklinker1, Yes, you are write, when we pass the type hint and fallback. It defaults to typehint and null condition. Will fix an update. Thanks |
@aklinker1 All 16 tests are passing now. |
@aklinker1 Why is it should changes required, I have made the changes please review them. Your reviewing part is left. Thanks. |
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.
Thanks!
Thanks, for approving the changes. As this is my first time contribution to open source, I am not aware of the steps involved. Are there more steps to this, as the pull request doesn't seem as it has been merged (please correct if wrong) even after you have approved. |
Just had to wait for checks to pass, just getting back to this now! |
Released in |
Changes
Updated the
getItem
function to check if the fallback parameter is provided. If it is, the function will return a non-null type.