打字稿定义修改
Typescript Definitions Modification
我需要对一些打字稿定义文件进行一些修改。到目前为止,我一直在手动进行这些修改 - 如果我清除我的 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。
我发现我可以通过将以下内容添加到我的 declarations.d.ts 文件来解决这个特定问题:
declare namespace PouchDB {
interface Static { adapter: any; }
}
我需要对一些打字稿定义文件进行一些修改。到目前为止,我一直在手动进行这些修改 - 如果我清除我的 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。
我发现我可以通过将以下内容添加到我的 declarations.d.ts 文件来解决这个特定问题:
declare namespace PouchDB {
interface Static { adapter: any; }
}