I'm trying to do include path in ts file tried may solutions available on stackoverflow but none works for me tsconfig.json
{
"compilerOptions": {
"strict": true,
"baseUrl": "./app",
"paths": {
"@redux/*": ["redux/*"]
},
"include": [
"./app/redux/**/*", "**/*.ts", "**/*.tsx"
],
},
"extends": "expo/tsconfig.base"
}
tsconfig.base.json
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Expo",
"compilerOptions": {
"allowJs": true,
"esModuleInterop": true,
"jsx": "react-native",
"lib": ["DOM", "ESNext"],
"moduleResolution": "node",
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"target": "ESNext"
},
"exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"]
}
trying to import in app.tsx
import {} from '@redux/store';// err Cannot find module '@redux/store' or its corresponding type declarations.
please suggest a solution (using in react app). have also tried for other paths like components.
structure - <root>/app/components <root>/app/redux/store.tsx
CodePudding user response:
Your paths are looking good.
You may need to use a tool like tsconfig-paths to resolve these path names.
You can then add something like the following in your package.json file where the build is executed.
ts-node -r tsconfig-paths/register ./src/app.ts
CodePudding user response:
Issue is resolved after adding alias in babel.config.js to project. read this