Typescript自动导入是从@types文件夹导入的
我在使用TypeScript和Webstorm的自动导入时遇到问题 导入是从Typescript自动导入是从@types文件夹导入的,typescript,Typescript,我在使用TypeScript和Webstorm的自动导入时遇到问题 导入是从@types文件夹而不是库文件夹导入的 例如,当我从express导入Request时,我得到: import { Request } from '@types/express'; 而不是 import { Request } from 'express'; 这是我的tsconfig.json { "compilerOptions": { "target": "ES2019", "module":
@types
文件夹而不是库文件夹导入的
例如,当我从express
导入Request
时,我得到:
import { Request } from '@types/express';
而不是
import { Request } from 'express';
这是我的tsconfig.json
{
"compilerOptions": {
"target": "ES2019",
"module": "commonjs",
"lib": [
"es2019"
],
"allowJs": true,
"sourceMap": true,
"outDir": "./build",
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"baseUrl": "./",
"paths": {
"*": [
"node_modules/*",
"src/types/*"
]
},
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"esModuleInterop": true,
"resolveJsonModule": true
},
"include": [
"src/**/*",
"migrations/*.ts"
],
"exclude": [
"node_modules",
"src/**/__tests-tape__/**",
"src/**/__tests__/**"
]
}
我可以制作typescript来正确解析类型吗 尝试从路径映射中删除“*”:[“node_modules/*”]
——这应该可以解决问题。不确定您为什么需要它,以及它与TypeScript对节点\ U模块的默认解析有何不同