Closed Crare closed 3 months ago
I have same issues.
{
"extends": "@react-native/typescript-config/tsconfig.json",
"compilerOptions": {
"baseUrl": "./src/",
"paths": {
"app-assets/*": ["assets/*"],
"app-components/*": ["components/*"],
"app-core/*": ["core/*"],
"app-forms/*": ["forms/*"],
"app-screens/*": ["screens/*"],
"app-*": ["*"]
}
}
}
It's work fine with react-native@0.72.x
happens too when upgrading to 0.73.5
added reproducible steps.
issue fixed with solution in react-native repo. closing this one too.
Still same in RN 0.73.6 @Crare . What is your config?
Still same in RN 0.73.6 @Crare . What is your config?
@luutruong you can use workspaces. https://classic.yarnpkg.com/lang/en/docs/workspaces/
I added workspaces to my package.json:
"workspaces": [
"./components",
"./components/common",
"./features",
"./configs",
"./api",
"./types",
"./utils",
"./services",
"./hooks",
"./screens",
"./assets"
],
then include in eact folder a corresponding package.json:
{
"name": "components",
"version": "1.0.0"
}
you can remote the paths and baseUrl from tsconfig.
It works now but it need run yarn
command after we set workspaces.
Still struggling to configure typescript. Im upgrading from 0.72.14 to 0.73.8 Previous typescript version was 4.8.4 and new 5.0.4
this is my tsconfig.json part abouth paths
"baseUrl": ".",
"paths": {
"@components/*": ["src/components/*"],
"@contexts/*": ["src/contexts/*"],
"@services/*": ["src/services/*"],
"@ui/*": ["src/ui/*"],
"@assets/*": ["src/assets/*"],
"@utils/*": ["src/utils/*"],
"@hooks/*": ["src/hooks/*"],
"@queries/*": ["src/queries/*"],
"@locales/*": ["src/locales/*"],
"@themes/*": ["src/themes/*"],
"@navigators/*": ["src/navigators/*"]
}
I created package.json files in each folder inside src folder like this one:
{
"name": "assets",
"version": "1.0.0"
}
I also added workspaces in my package.json like this :
"workspaces": [
"src/components/*",
"src/contexts/*",
"src/services/*",
"src/ui/*",
"src/assets/*",
"src/utils/*",
"src/hooks/*",
"src/queries/*",
"src/locales/*",
"src/themes/*",
"src/navigators/*"
]
I ran yarn in my project root as @luutruong suggested but nothing changed. Still i face the same issue. Any suggestions guys?
Environment
Things I’ve done to figure out my issue
Upgrading version
from RN 0.72.9 to 0.73.2
Description
Error:
Error in tsconfig probably due to changes in "extends" value there. extends used to be
"extends": "@tsconfig/react-native/tsconfig.json",
tsconfig:
components-folder and other such are in the root. not under src-folder or such.
Reproducible demo
either use the steps below or clone https://github.com/Crare/rn0.73.x_tsxonfig_paths_issue
export const TestComponent = () => { return (
); }
... import {TestComponent} from 'components/testComponent'; ... function App(): React.JSX.Element { const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = { backgroundColor: isDarkMode ? Colors.darker : Colors.lighter, };
return (
); } ...
{ "extends": "@react-native/typescript-config/tsconfig.json", "compilerOptions": { "baseUrl": ".", "paths": { "components/": ["components/"] } } }