全域性 type 型別的尋找 typescript 型別 - fabric.Canvas

彭成刚發表於2024-06-06

全域性 type型別的尋找 typescript 型別 - fabric.Canvas

declare type ExtCanvas = fabric.Canvas & {
  isDragging: boolean;
  lastPosX: number;
  lastPosY: number;
};

這個程式碼 沒有定義 fabric.Canvas,然後看看提示

說在namespace定義了。這個是子專案,沒有type定義,上父專案尋找

在父專案中找到了,全域性定義
這個定義的引入是在

父專案的tsconfig.josn 裡面的 include陣列的 "typings/**/*.ts", 設定的。

相關文章