wxt icon indicating copy to clipboard operation
wxt copied to clipboard

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

Open avi12 opened this issue 1 year ago • 3 comments

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

avi12 avatar Oct 03 '24 10:10 avi12

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

Timeraa avatar Oct 03 '24 14:10 Timeraa

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

aklinker1 avatar Oct 04 '24 00:10 aklinker1

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

Timeraa avatar Oct 04 '24 17:10 Timeraa