Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/windows-phone-7/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript自动导入是从@types文件夹导入的_Typescript - Fatal编程技术网

Typescript自动导入是从@types文件夹导入的

Typescript自动导入是从@types文件夹导入的,typescript,Typescript,我在使用TypeScript和Webstorm的自动导入时遇到问题 导入是从@types文件夹而不是库文件夹导入的 例如,当我从express导入Request时,我得到: import { Request } from '@types/express'; 而不是 import { Request } from 'express'; 这是我的tsconfig.json { "compilerOptions": { "target": "ES2019", "module":

我在使用TypeScript和Webstorm的自动导入时遇到问题

导入是从
@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模块的默认解析有何不同