-
-
Notifications
You must be signed in to change notification settings - Fork 432
Open
Labels
pending-triageSomeone (usually a maintainer) needs to look into this to see if it's a bugSomeone (usually a maintainer) needs to look into this to see if it's a bug
Description
Describe the bug
Bug:
Init no longer functions correctly after updating from wxt-dev/storage 1.1.1 to the 1.2.6.
For example, if I define an item with:
const example = storage.defineItem<boolean[]>(
'local:exampleItemArray',
{ init: () => [] }
);
I start getting 'example' is possibly 'null'.
Expectation:
The init option should also narrow the type to non-null (like fallback does), since it guarantees a value will always exist. This is either a type oversight or a regression in the overload signatures.
Reproduction
const example = storage.defineItem<boolean[]>(
'local:exampleItemArray',
{ init: () => [] }
);
Steps to reproduce
Define an item with init instead of fallback.
System Info
System:
OS: macOS 14.5
CPU: (8) arm64 Apple M2
Memory: 250.27 MB / 24.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.17.0 - /Users/ianleck/.nvm/versions/node/v20.17.0/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.8.2 - /Users/ianleck/.nvm/versions/node/v20.17.0/bin/npm
pnpm: 10.17.0 - /Users/ianleck/.nvm/versions/node/v20.17.0/bin/pnpm
Deno: 2.1.4 - /Users/ianleck/.deno/bin/deno
Browsers:
Brave Browser: 142.1.84.141
Chrome: 142.0.7444.176
Firefox: 145.0
Safari: 17.5
npmPackages:
wxt: ^0.20.11 => 0.20.11Used Package Manager
pnpm
Validations
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
pending-triageSomeone (usually a maintainer) needs to look into this to see if it's a bugSomeone (usually a maintainer) needs to look into this to see if it's a bug