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.58k stars 109 forks source link

[Bug] Typescript problem - Cannot find namespace 'MMKVStorage' #236

Closed unfernandito closed 2 years ago

unfernandito commented 2 years ago

Describe the bug

Hello @ammarahm-ed how are you?

The latest version broke my typescript build, looks like cannot find the index.d.ts file in the package.

To Reproduce Steps to reproduce the behavior:

  1. Install the latest version (0.7.1)
  2. Run the tsc command

Expected behavior Build my typescript code.

Screenshots image

Platform Information:

Additional context I tried with the 0.7.0 version and got the same error.

ammarahm-ed commented 2 years ago

That's strange because the latest version comes with pre built js and d.ts files in dist folder. Try deleting node_modules folder then run npm install again.

unfernandito commented 2 years ago

i'll try

unfernandito commented 2 years ago

After run a fresh install i got the same behavior, my tsc continue broken, looks like something related to my tsconfig, i'll try update typescript to 4.5 version

unfernandito commented 2 years ago

i've updated to typescript 4.5.5 and continue failing me, i'll try some other stuff and if i find something, i'll send you a PR

unfernandito commented 2 years ago

@ammarahm-ed i can't make a fork to try to fix it, but i think is broken the reference to the declaration files. I think this problem it's related to my config. but i can't figure out which could be the issue.

In other way, i think the dist folder should only exist while is running the publish action, right now your dist folder is outdated, if you run the npm run build script, the files changed and maybe something is failing.

ammarahm-ed commented 2 years ago

I think the type MMKVStorage.API does not exist in the latest typings which is why you are getting this error

unfernandito commented 2 years ago

https://github.com/ammarahm-ed/react-native-mmkv-storage/blob/master/dist/index.d.ts#L9

Seems exist in the declaration file, it's so weird.

ammarahm-ed commented 2 years ago

@unfernandito Can you try the master branch? I have fixed this.

Use import {API} from "react-native-mmkv-storage" instead for types

unfernandito commented 2 years ago

i'll try it

unfernandito commented 2 years ago

Ok, API namespace it's fixed, but all the others are no exported, how can i contribute you with this changes?

The repo seems to be reach the maximum forks allowed

ammarahm-ed commented 2 years ago

@unfernandito You have already forked it I think. Check your repositories list. Which others are you using?

unfernandito commented 2 years ago

🕺 i'm so dumb, you are right, i've already forked this repo

unfernandito commented 2 years ago

https://github.com/ammarahm-ed/react-native-mmkv-storage/pull/239

ammarahm-ed commented 2 years ago

Hey @unfernandito Can you try the master again and see if it resolves all errors? The PR you have sent is a breaking change and I am looking for a way to not break the API. You can now export MMKVStorageInterface for any types you need.

unfernandito commented 2 years ago

I'll try, thanks you

El mar., 19 de abril de 2022 4:28 p. m., Ammar Ahmed < @.***> escribió:

Hey @unfernandito https://github.com/unfernandito Can you try the master again and see if it resolves all errors? The PR you have sent is a breaking change and I am looking for a way to not break the API. You can now export MMKVStorageInterface for any types you need.

— Reply to this email directly, view it on GitHub https://github.com/ammarahm-ed/react-native-mmkv-storage/issues/236#issuecomment-1103012695, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQIPKXXAIICXUAT2V3HFRDVF4CORANCNFSM5TVZI7UA . You are receiving this because you were mentioned.Message ID: @.***>

unfernandito commented 2 years ago

image

Same behavior :/

unfernandito commented 2 years ago

image

i've change the code to this and seems work again.

unfernandito commented 2 years ago

@ammarahm-ed could you publish this version in npm plz?

The latest commit can be applied as a fix to this issue 😄

unfernandito commented 2 years ago

Hi @ammarahm-ed how are you?

Could you publish the 0.7.3 version with the latests changes?

If you need some help, i'm available to contribute you in this repository.

ammarahm-ed commented 2 years ago

@unfernandito I will merge the changes after undoing my last commits

unfernandito commented 2 years ago

Thanks you

El mié., 27 de abril de 2022 8:12 a. m., Ammar Ahmed < @.***> escribió:

@unfernandito https://github.com/unfernandito I will merge the changes after undoing my last commits

— Reply to this email directly, view it on GitHub https://github.com/ammarahm-ed/react-native-mmkv-storage/issues/236#issuecomment-1110875699, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQIPKRDLSXRSV4AG7VQFZ3VHEOLVANCNFSM5TVZI7UA . You are receiving this because you were mentioned.Message ID: @.***>

ammarahm-ed commented 2 years ago

@unfernandito Check the latest master branch. Use import {MMKVLoader} from "react-native-mmkv-storage". I have renamed exports to more readable forms.

API is renamed to MMKVInstance Loader is renamed to MMKVLoader

unfernandito commented 2 years ago

Thanks friend. I'll try tomorrow and come back with the results.

unfernandito commented 2 years ago

All it's working well, this change will be breaking change?

unfernandito commented 2 years ago

My fault :(

ammarahm-ed commented 2 years ago

@unfernandito No it won't be a breaking change. Only deprecating previous API but it still works the same way.

ammarahm-ed commented 2 years ago

I will close this. Will ship it in 0.7.2

unfernandito commented 2 years ago

Thanks for all this work!