0

我需要對某些打字稿定義文件進行一些修改。到目前爲止,我一直在手動進行這些修改 - 如果我刪除node_modules目錄並重新開始,或者如果我在新機器上安裝我的代碼,則會有點痛苦。但是這些改變只是很小而且很有效。但是現在我想使用一個調用npm install作爲構建過程的一部分的服務來構建我的代碼 - 當然,我的修改對於此過程是未知的。我包括我有下面進行修改的一個:手稿定義修改

Add the following: 
adapter(param1: string, param2: any): Static; 

After the first line in node_modules\@types\pouchdb-core\index.d.ts in the following Interface: 
interface Static extends EventEmitter 

In order to avoid an error with the following statement in data-service.ts: 
PouchDB.adapter('writableStream', replicationStream.adapters.writableStream); 

我的問題是如何使這種類型的修改我node_modules目錄以外的,使外部構建過程會了解必要的修改。

我正在使用使用Webpack的Ionic 2。

+0

看你怎麼導入你要修改的模塊,這將是有益的。 –

+0

@JamesMonger我爲PouchDB使用了一個簡單的導入語句:從'pouchdb'導入PouchDB; – daveywc

+0

對於我的一個項目,我在我的package.json中添加了一個「postinstall」步驟,該步驟運行bash腳本進行修改。這樣做的正確方法可能是分叉回購。 –

回答

0

我發現我可以通過添加以下到我的declarations.d.ts文件解決此特定問題:

declare namespace PouchDB { 
    interface Static { adapter: any; } 
} 
+0

是你在源代碼控制中的'declarations.d.ts'文件嗎? –