Reputation: 791
I have a file in src/shared/components/A.tsx
that does import B from 'components/B'
(src/shared/components/B.tsx
)
Typescript gives me an error cannot find module 'components/B'
This is my tsconfig.json
file which is in the root directory:
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"module": "es6",
"target": "es6",
"jsx": "react",
"allowJs": true,
"moduleResolution": "node"
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules"
],
"baseUrl": ".",
"paths": {
"*": [
"*",
"src/shared/*" //this doesn't seem to work
]
}
}
My understanding from https://www.typescriptlang.org/docs/handbook/tsconfig-json.html is that it will try to find ./components/B
first, which does not exist, then go into <baseUrl>/src/shared/components/B
, which is where the file exists, so I'm not sure why I'm still seeing an error.
Upvotes: 0
Views: 643