使用nodejs在TS中没有出现编译时错误

问题描述 投票:0回答:1

我在nodejs中使用typescript,并且没有收到任何编译时错误,特别是在使用ES6模块语法时。

没有 ES6 模块语法——按预期工作: enter image description here enter image description here

使用 ES6 模块语法 -- 无法按预期工作: enter image description here

如果有任何帮助,这是我的

tsconfig.json
文件:

{
    "compilerOptions": {
      "target": "ESNext",
      "module": "ESNext",
      "strict": true,
      "noImplicitAny": true,
      "esModuleInterop": true,
      "skipLibCheck": true,
      "forceConsistentCasingInFileNames": true
    },
    "include": ["**/*.ts", "eslint.config.mjs"], // checks every ts/tsx file
    "exclude": ["node_modules", "**/*.spec.ts"]
}
node.js typescript
1个回答
0
投票

您的程序中有导入错误,似乎没有安装 Express 类型。

express 安装类型:

npm install @types/node @types/express --save-dev

然后再检查一下

© www.soinside.com 2019 - 2024. All rights reserved.