Skip to content

Commit

Permalink
fix: typescript paths (#2182)
Browse files Browse the repository at this point in the history
## 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

<!--

## Screenshots / GIFs

Here you can add screenshots / GIFs documenting your change.

You can add before / after section if you're changing some behavior.

### Before

### After

-->

## Test code and steps to reproduce

<!--
Please include code that can be used to test this change and short
description how this example should work.
This snippet should be as minimal as possible and ready to be pasted
into editor (don't exclude exports or remove "not important" parts of
reproduction example)
-->

## Checklist

- [ ] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Updated documentation: <!-- For adding new props to native-stack
-->
- [ ]
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
  • Loading branch information
alduzy committed Jun 14, 2024
1 parent 537fd63 commit ea85934
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
9 changes: 8 additions & 1 deletion apps/examples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
7 changes: 7 additions & 0 deletions apps/test-examples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ea85934

Please sign in to comment.