I’m working on a project and I set up absolute path imports in my project. But, it doesn’t resolve to the index file if I put only up to the folder name.
src
|--modules
|--search
|--utils.ts
|--index.ts
When I import,
import { something } from 'modules/search/index'
it works fine.
But, I when I import like
import { something } from 'modules/search'
It says, src/modules/search.ts
not found.
Following is my tsconfig.json
.
{
"compileOnSave": false,
"compilerOptions": {
"rootDir": ".",
"strict": true,
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"module": "esnext",
"lib": ["es2017", "dom"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"baseUrl": "src",
},
"exclude": ["node_modules", "tmp"]
}
How can I solve this problem?
The expected behavior is,
import { something } from 'modules/search'
should resolve to src/modules/search/index.ts
import { something } from 'modules/search/utils'
should resolve to src/modules/search/utils.ts