我使用的組件react-router-bootstrap和定義從DefinitelyTyped。我的問題是下載的定義與組件不匹配。我已經創建了一個可以解決這個問題的拉取請求,但由於我不知道什麼時候會修補,所以我必須重寫它。我不能僅僅編輯位於node_modules\@types
的類型定義文件,因爲我們是一個團隊在這個項目上工作,並且node_modules
文件夾沒有簽入。覆蓋V2.2.2中的TypeScript類型從NPM下載@Type
如何覆蓋類型定義?由於其他文件的工作原因,我只想重寫LinkContainer.d文件。
拉請求:
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/16600
我試圖創建一個在我的分型文件夾命名爲LinkContainer.d.ts
文件,該文件是正確的,但它不會回升。在同一個文件夾中,我有一個global.d.ts
,接口可以很好地接收。基於這個例子
/// <reference types="react-router-bootstrap" />
import { ComponentClass } from "react";
import { NavLinkProps } from "react-router-dom";
type LinkContainer = ComponentClass<NavLinkProps>;
declare const LinkContainer: LinkContainer;
export default LinkContainer;