Here is my tsconfig:
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": false,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": false,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true,
"baseUrl": "./",
"paths": {
"@": ["./src"],
"@shared": ["./shared/*"]
}
},
"include": ["src"]
}
This is the structuer of my project:
.
├── bun.lockb
├── Dist
├── index.html
├── node_modules
├── package.json
├── public
├── shared
├── src
└── tsconfig.json
This line import greet from '@shared/greet'
in src/main.ts
is reported:
Cannot find module '@shared/greet' or its corresponding type declarations.ts(2307)
I don’t get it since I already configured baseUrl and paths in tsconfig.json, why tsc failed to locate shared/greet
try ‘@shared/*’ for path key and make sure your path is pointing to the correct dir
New contributor
Vyahruth Netcherla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.