typescript - 将 typescript 升级到 4.2.x,导入路径不能以“.ts”结尾?
问题描述
当我将 typescript 从 4.1.5 升级到 4.3.2 时,我的程序无法构建。
错误信息:导入路径不能以“.ts”扩展名结尾。考虑改为导入“@/api/common.js”。
4.1.5版本还可以。4.2.x以后就不能用.ts扩展了吗?
我的 tsconfig.json:
{
"compilerOptions": {
"target": "es2019",
"module": "esnext",
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"jsx": "preserve",
"incremental": true,
"isolatedModules": true,
"strict": true,
"resolveJsonModule": true,
"importHelpers": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"skipLibCheck": true,
"noUnusedLocals": false,
"types": [
"webpack-env",
"jest"
],
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"includes": ["../shared/**/**"],
"exclude": [
"node_modules"
]
}
解决方案
推荐阅读
- python - 循环遍历两个列表并更新一个列表的元素
- python - 在 Django 中从没有表单的 POST 中检索信息
- c# - 如何使用 base64 链接在电子邮件附件中发送 base64 图像?
- django - 如何从表单中排除外国人的关键字段
- angular-material - 禁用和启用芯片列表
- html - Angular 8 - 初始加载时值更改和模板渲染之间的延迟
- r - 根据数字位置拆分数字
- css - 用于 mat-list 的 CSS 媒体查询
- android - 升级构建版本得到更新,但文件不更新(缓存删除)
- python - 为什么 cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 的输出形状发生了变化?