のマージ、私は言及していたプロジェクトはここにある:https://github.com/abauzac/nightwatch-typescriptは、問題を暴露する前にtypescriptです外部グローバルインターフェイスと継承
私の問題は、ナイトウォッチの定義である、それは(ない名前空間内のグローバルインタフェースの多くをエクスポートしたり、
./node_modules/@types/nightwatch:含むモジュールhttps://github.com/DefinitelyTyped/DefinitelyTyped/blob/38bd4efd5dc8c666f70d77b020a0b64a13ce3980/types/nightwatch/index.d.ts)、ナイトウォッチへ
export interface NightwatchCustomCommands { /* empty interface */ }
export interface NightwatchCustomAssertions { /* empty interface */ }
export interface NightwatchBrowser extends NightwatchCustomCommands, NightwatchCustomAssertions, ... { ... }
export interface NightwatchAssertions extends NightwatchBrowser { ... }
私が追加したカスタムコマンドとアサーションとはNightwatchCustomCommandsをマージしようとしましたが、 NightwatchCustomAssertions:
./types/index.d.ts
import { NightwatchAssertions, NightwatchBrowser } from "nightwatch";
// merge interfaces with nightwatch types
interface NightwatchCustomAssertions {
compareScreenshot(this: NightwatchBrowser, filename: string, expected: number, callback: Function);
}
interface NightwatchCustomCommands {
wplogin(this: NightwatchBrowser, callback?: Function):this;
compareScreenshot(this: NightwatchBrowser, filename: string, expected?: number, callback?: Function)
}
が、コンパイル時にインターフェースがマージされていないようだ。
Property 'wplogin' does not exist on type 'NightwatchBrowser'.
Property 'compareScreenshot' does not exist on type 'NightwatchAssertions'.
両方@typesと種類のフォルダがTSconfigの中に含まれています"typeRoots"これまでのところ、インターフェイスに "エクスポート"を追加しようとしましたが、名前空間には何が欠けているのか分かりません。
私は実際には問題の一部であり、どのようなコード言うことができないあなたがしようとしたものが何であると捨てられました。あなたが試みているコードだけを表示すると、私は助けることができます。たとえば、2番目のコードブロックでは、継承を行っていないので、私はあなたの意図が何であるかを知ることができません。 –
私がしようとしているのは、ここの2番目のセクションで説明したようなインターフェースをマージすることです:https://www.typescriptlang.org/docs/handbook/declaration-merging.html。継承されたインターフェイス(最初のブロック)で考慮する私のインターフェイス(2番目のブロック)を参照することを期待しています – bqlou