ammarahm-ed / react-native-mmkv-storage

An ultra fast (0.0002s read/write), small & encrypted mobile key-value storage framework for React Native written in C++ using JSI
https://rnmmkv.now.sh
MIT License
1.56k stars 109 forks source link

Using TypeScript the docs don´t work #304

Open ViniDevBR opened 1 year ago

ViniDevBR commented 1 year ago

Describe the bug Just giving a copy and paste in the code in the cods using the hook useMMKVStorage() 1° - const MMKV: MMKVStorage.API = new MMKVLoader().initialize() TS say: 'MMKVStorage' refers to a value, but is being used as a type here. Did you mean 'typeof MMKVStorage' but using typeof MMKVStorage.API this returns error 2° - const [value, setValue] = useStorage(' ') - When i press CTRL+SPACE, to see the options, this returns nothing

Hacks When i just use ----> key: 'clientList' | 'totalDay' | 'totalMonth' ------ Without the LiteralUnion the TS returns my 3 options

Screenshots image

THIS WORKS image image

FIX Doing this, will work, but keeping the (U =string), if i put any string inside my hook this wont send error because U accepts string too. image

Platform Information:

Mookiies commented 1 year ago

For issue the first issue MMKVLoader().initialize() returns type MMKVInstance