I have been attempting to set up React Native with absolute paths for easier imports, but I am having trouble getting it to work. Here is my tsconfig.json:
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["es6"],
"moduleResolution": "node",
"noEmit": true,
"strict": true,
"target": "esnext",
"baseUrl": "src"
},
"include": ["src"],
"exclude": [ "node_modules", "babel.config.js", "metro.config.js"]
}
As for babel.config.js:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [['module-resolver', { root: ['./src'] }]],
}
I have tried various configurations, including different combinations of
"baseUrl":"src"
, "paths":{"*":["./src/*"]}
, and so on. Despite VS Code recognizing the imports correctly, the app crashes when running with absolute paths. Am I missing something obvious here?