wxt-dev / wxt

⚡ Next-gen Web Extension Framework
https://wxt.dev
MIT License
4.46k stars 185 forks source link

`unknown` should be used instead of `any` for `getItems` #1025

Open avi12 opened 1 month ago

avi12 commented 1 month ago

Describe the bug

I noticed that in this snippet, value's type is any https://github.com/wxt-dev/wxt/blob/d2702506332c03f40bfda9b3b59e4c4928e3099b/packages/wxt/src/storage.ts#L481-L485

I'm pretty sure the type should rather be unknown | null

Steps to reproduce

No response

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (20) x64 Intel(R) Core(TM) i7-6950X CPU @ 3.00GHz
    Memory: 37.10 GB / 63.91 GB
  Binaries:
    Node: 20.14.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.11.0 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.19041.4355
  npmPackages:
    wxt: ^0.19.10 => 0.19.10

Used Package Manager

pnpm

Validations

Timeraa commented 1 month ago

It would make it type safer but it also comes at a high compromise and that is that you are forced to check the types etc. and that would add complexity especially for beginners with TypeScript. Generally you'd be using the defineItem stuff either way

aklinker1 commented 1 month ago

I can see both sides. Might be worth switching to unknown for v2, once storage is extracted.

Timeraa commented 1 month ago

I mean I personally am for it just thinking about others haha