From ea85934551e9321fe19075efe4f6e10b9279b8a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Du=C5=BCy?= <91994767+alduzy@users.noreply.github.com> Date: Fri, 14 Jun 2024 10:17:00 +0200 Subject: [PATCH] fix: typescript paths (#2182) ## Description This PR fixes the errors showing on `yarn prepare` command. Turned out that custom path definition to react-navigation folder produced typescript errors when running the command. The default node_modules directory contains typescript definitions that do not cause any problems. ~~Some of the react-navigation packages were missing in node modules and the ts support was missing in examples so I added them as devDependencies - now there are no errors during the prepare command and there is full TS support in common examples directory.~~ ~~The alternative approach would be to define compilerOptions paths pointing to react-navigation folder inside examples and test-examples tsconfigs individually instead of adding new devDependencies~~ Edit: decided to go with the second approach as it does not add any extra dependencies - the tsconfigs inside common example directories redefine paths. ## Changes - removed custom paths to react-navigation types (node_modules is the default) - added the paths to react-navigation types individually in apps/examples and apps/test-examples ## Test code and steps to reproduce ## Checklist - [ ] Included code example that can be used to test this change - [ ] Updated TS types - [ ] Updated documentation: - [ ] https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md - [ ] https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md - [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx - [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx - [ ] Ensured that CI passes --- apps/examples/tsconfig.json | 9 ++++++++- apps/test-examples/tsconfig.json | 7 +++++++ tsconfig.json | 3 +-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/examples/tsconfig.json b/apps/examples/tsconfig.json index c42678a9c7..9466ebbae0 100644 --- a/apps/examples/tsconfig.json +++ b/apps/examples/tsconfig.json @@ -1,4 +1,11 @@ { "extends": "../../tsconfig.json", - "include": ["**/*.ts", "**/*.tsx", "**/*.js"], + "compilerOptions": { + "paths": { + "react-native-screens": ["src"], + "react-native-screens/*": ["src/*"], + "@react-navigation/*": ["react-navigation/packages/*/src"] + } + }, + "include": ["**/*.ts", "**/*.tsx", "**/*.js"] } diff --git a/apps/test-examples/tsconfig.json b/apps/test-examples/tsconfig.json index 19aefad26a..9466ebbae0 100644 --- a/apps/test-examples/tsconfig.json +++ b/apps/test-examples/tsconfig.json @@ -1,4 +1,11 @@ { "extends": "../../tsconfig.json", + "compilerOptions": { + "paths": { + "react-native-screens": ["src"], + "react-native-screens/*": ["src/*"], + "@react-navigation/*": ["react-navigation/packages/*/src"] + } + }, "include": ["**/*.ts", "**/*.tsx", "**/*.js"] } diff --git a/tsconfig.json b/tsconfig.json index bb85e1ba00..e79dd74079 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,8 +3,7 @@ "baseUrl": ".", "paths": { "react-native-screens": ["src"], - "react-native-screens/*": ["src/*"], - "@react-navigation/*": ["react-navigation/packages/*/src"] + "react-native-screens/*": ["src/*"] }, "allowUnreachableCode": false, "allowUnusedLabels": false,