亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

TS報錯Cannot?find?module?'xxx'?or?its?corresponding?type?declarations解決

 更新時間:2023年08月18日 08:53:16   作者:天問  
這篇文章主要為大家介紹了TS報錯Cannot?find?module?'xxx'?or?its?corresponding?type?declarations解決,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

import 導(dǎo)入后出現(xiàn)了 TS 報錯

最近使用 vite + vue3 + ts 開發(fā)一個文本標(biāo)注的 web 平臺,在項(xiàng)目中使用了一個 js-mark 的 npm 包,但是在 import 導(dǎo)入后出現(xiàn)了 TS 報錯:

TS2307: Cannot find module 'js-mark' or its corresponding type declarations.、無法解析模塊 'js-mark' 的定義

TS declare module

報錯原因

依賴引入報錯是因?yàn)閠s沒有識別當(dāng)前引入的依賴

問題解決

src/vite-env.d.ts 文件中聲明該依賴即可解決,語法:declare module "xxx"。

例:聲明 js-mark 模塊依賴:

/// <reference types="vite/client" />
declare module "js-mark";
// 解決找不到模塊“*.vue”或其相應(yīng)的類型聲明。
declare module "*.vue" {
  import { DefineComponent } from "vue";
  const component: DefineComponent<{}, {}, any>;
  export default component;
}

以上就是TS報錯Cannot find module 'xxx' or its corresponding type declarations解決的詳細(xì)內(nèi)容,更多關(guān)于TS報錯解決的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評論