th3rdwave / react-native-safe-area-context

A flexible way to handle safe area insets in JS. Also works on Android and Web!
MIT License
2.09k stars 191 forks source link

[4.6.0] missing types #401

Closed efstathiosntonas closed 1 year ago

efstathiosntonas commented 1 year ago

Latest release 4.6.0 is missing types.

Screenshot 2023-06-21 at 09 59 27

efstathiosntonas commented 1 year ago

For some reason it imports from commonjs folder instead of typescript one 🤔, tsc is returning:

xxxx/test.tsx:32:35 - error TS7016: Could not find a declaration file for module 'react-native-safe-area-context'. '/Users/stathis/IdeaProjects/xxxxx/node_modules/react-native-safe-area-context/lib/commonjs/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/react-native-safe-area-context` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-native-safe-area-context';`

32 import { useSafeAreaInsets } from "react-native-safe-area-context";
chj-damon commented 1 year ago

I'm facing the same issue.

efstathiosntonas commented 1 year ago

This line: https://github.com/th3rdwave/react-native-safe-area-context/blob/b8b1e8e4ab5e9ca4901ca04d21dd4a000a424ab1/package.json#L8

should be:

  "types": "lib/typescript/src/index.d.ts",

it seems bob-builder messed up somehow?

jacobp100 commented 1 year ago

Fixed in #400

efstathiosntonas commented 1 year ago

thanks @jacobp100

efstathiosntonas commented 1 year ago

patch just in case someone can't wait for a release:

react-native-safe-area-context+4.6.0.patch

diff --git a/node_modules/react-native-safe-area-context/package.json b/node_modules/react-native-safe-area-context/package.json
index 68f30e6..db9bdfe 100644
--- a/node_modules/react-native-safe-area-context/package.json
+++ b/node_modules/react-native-safe-area-context/package.json
@@ -5,7 +5,7 @@
   "main": "lib/commonjs/index.js",
   "module": "lib/module/index.js",
   "react-native": "src/index.tsx",
-  "types": "lib/typescript/index.d.ts",
+  "types": "lib/typescript/src/index.d.ts",
   "source": "src/index.tsx",
   "sideEffects": false,
   "files": [