colorfy-software / react-native-modalfy

🥞 Modal citizen of React Native.
https://colorfy-software.gitbook.io/react-native-modalfy
MIT License
1.08k stars 44 forks source link

Type Error Upon Installation #21

Closed enaluz closed 4 years ago

enaluz commented 4 years ago

Awesome library everyone! I haven't integrated it into our production version yet, but we plan to as soon as we can get it working.

Upon installation, I got this type error. Any ideas on what could fix this? I've tried nuking and reinstalling node_modules. I'm using yarn, and node version v12.4.0.

node_modules/react-native-modalfy/utils/getStackItemData.ts:1:36 - error TS7016: Could not find a declaration file for module 'react-is'. '<OmittedPath>/mobile/node_modules/react-is/index.js' implicitly has an 'any' type.
  Try `npm install @types/react-is` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-is';`

1 import { isValidElementType } from 'react-is'
                                     ~~~~~~~~~~

node_modules/react-native-modalfy/utils/getStackItemData.ts:3:30 - error TS2307: Cannot find module 'types' or its corresponding type declarations.

3 import { ModalOptions } from 'types'
                               ~~~~~~~

Thank you in advance 😄

enaluz commented 4 years ago

Update: I fixed it! It was super simple. Just resolved the path to the types file, and had to install @types/react-is as a dev dependency in the parent project (my app root). Here is the patch generated by patch-package:

diff --git a/node_modules/react-native-modalfy/utils/getStackItemData.ts b/node_modules/react-native-modalfy/utils/getStackItemData.ts
index ece3ba7..b3d0405 100644
--- a/node_modules/react-native-modalfy/utils/getStackItemData.ts
+++ b/node_modules/react-native-modalfy/utils/getStackItemData.ts
@@ -1,6 +1,6 @@
 import { isValidElementType } from 'react-is'

-import { ModalOptions } from 'types'
+import { ModalOptions } from '../types'

 export default function <P>(
   modalName: Exclude<keyof P, symbol | number>,
CharlesMangwa commented 4 years ago

Hey @enaluz! Thanks for the heads up! The ../types one is on us yeah, will fix it for the upcoming patch release. I hope you'll enjoy Modalfy and feel free to reach out if needed!