error TS2691: An import path cannot end with a '.ts' extension. Consider importing '@/types/index.js' instead. import { myAMap } from '@/types/index.ts'
這個(gè)是由于使用了 別名 alias 導(dǎo)致的。
以 tsconfig.json 的拓展形式兼容配置
# 在tsconfig.json 文件中加入這一句
"extends": "./tsconfig.extends.json"
按照目錄 創(chuàng)建 tsconfig.extends.json 文件
# tsconfig.extends.json 輸入一下內(nèi)容
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
}
}
報(bào)錯(cuò)如圖

extends.png

alias error.png