my directory structure is:
|
|__src
| |_components
| |
| |_A
| |_index.tsx
|
|
tsconfig.json
package.json
I want to import A
like this:
import { A } from 'src/components/A';
My tsconfig.json looks like this:
{
"compilerOptions": {
"baseUrl": "",
"declaration": true,
"downlevelIteration": true,
"esModuleInterop": true,
"jsx": "react",
"lib": ["es5", "es2015", "es2016", "dom"],
"module": "esnext",
"moduleResolution": "node",
"noImplicitAny": true,
"noUnusedLocals": true,
"noImplicitReturns": true,
"outDir": "dist",
"removeComments": false,
"skipLibCheck": true,
"strict": true,
"strictFunctionTypes": false,
"strictNullChecks": false,
"suppressImplicitAnyIndexErrors": true,
"target": "es5",
"typeRoots": ["./node_modules/@types"],
"types": ["node", "jest"],
"paths": {
"*": ["./node_modules/@types/*", "./types/*"]
}
},
"include": ["src/**/*.ts", "src/**/*.tsx"],
"exclude": ["./node_modules", "./dist", "src/**/*.test.ts", "src/**/*.test.tsx"]
}
But the import does not work and I get the error:
can't find module 'src/components/A';
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…