vue3+typscript项目中不能 import ".ts
作者:
东方三篇 | 来源:发表于
2021-09-02 10:36 被阅读0次
error TS2691: An import path cannot end with a '.ts' extension. Consider importing '@/types/index.js' instead. import { myAMap } from '@/types/index.ts'
这个是由于使用了 别名 alias 导致的。
以 tsconfig.json 的拓展形式兼容配置
# 在tsconfig.json 文件中加入这一句
"extends": "./tsconfig.extends.json"
按照目录 创建 tsconfig.extends.json 文件
# tsconfig.extends.json 输入一下内容
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
}
}
报错如图

extends.png

alias error.png
本文标题:vue3+typscript项目中不能 import ".ts
本文链接:https://www.haomeiwen.com/subject/vvmqwltx.html
网友评论