Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript support in beta #67

Open
samducker opened this issue Sep 2, 2024 · 2 comments
Open

Typescript support in beta #67

samducker opened this issue Sep 2, 2024 · 2 comments

Comments

@samducker
Copy link

Hi I have migrated to the beta as I could not get the previous versions to work at all in Expo SDK 52.

However I get this typescript error with the latest.

Could not find a declaration file for module 'react-native-shake'. '/Users/sam/project/node_modules/react-native-shake/lib/commonjs/index.js' implicitly has an 'any' type.
  There are types at ''/Users/sam/project/node_modules/react-native-shake/lib/typescript/module/src/index.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.ts(7016)
@Doko-Demo-Doa
Copy link
Owner

Doko-Demo-Doa commented Sep 2, 2024

Hi @samducker as you can see in the suggestion, you may need to change moduleResolution field to Bundler. E.g:

{
  "extends": "expo/tsconfig.base",
  "compilerOptions": {
    "strict": true,
    "moduleResolution": "Bundler", // <-- this one
    "baseUrl": ".",
    "paths": {
      "~/*": ["src/*"],
      "@assets/*": ["assets/*"]
    }
  },
  "include": ["**/*.ts", "**/*.tsx", ".expo/types/**/*.ts", "expo-env.d.ts"]
}

@jeroen-van-dijk
Copy link

jeroen-van-dijk commented Oct 23, 2024

I have applied a patch to be able to find the types:

diff --git a/node_modules/react-native-shake/package.json b/node_modules/react-native-shake/package.json
index 3dd6c0a..137d0fc 100644
--- a/node_modules/react-native-shake/package.json
+++ b/node_modules/react-native-shake/package.json
@@ -5,6 +5,7 @@
   "source": "./src/index.tsx",
   "main": "./lib/commonjs/index.js",
   "module": "./lib/module/index.js",
+  "types": "./lib/typescript/module/src/index.d.ts",
   "exports": {
     ".": {
       "import": {
@@ -15,7 +16,8 @@
         "types": "./lib/typescript/commonjs/src/index.d.ts",
         "default": "./lib/commonjs/index.js"
       }
-    }
+    },
+    "./types": "./lib/typescript/module/src/index.d.ts"
   },
   "files": [
     "src",

I have opened a PR: #75

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants