上のキー:アクセス私はこれが可能だと思うが、これを与えられていないtypescriptですインターフェイス
インタフェース
import {BrowserService} from "../services/browser/index";
export interface IPrimaryNavigation {
opts:IPrimaryNavigationOpts;
}
export interface IPrimaryNavigationOpts {
...
browserService:BrowserService;
...
}
クラス:どうすればよい
import {IPrimaryNavigation, IPrimaryNavigationOpts} from "./interface";
export class PrimaryNavigation implements IPrimaryNavigation {
public opts:IPrimaryNavigationOpts;
...
mounted():void {
...
this.listenForBootstrap(this.opts.bsNav, this.opts.browserService);
}
listenForBootstrap(menuName:string,browserService:<???>):void {
^^^ here is the problem -
// I want to do the equivalent of IPrimaryNavigationOpts.browserService but can't.
// I don't think I should have to import the IBrowserService explicitly.
}
}
あなたはこの問題を回避します。私はこのような問題に対処するオンラインの例は見つけられないようです。私はこれのすべてに非常に新しいので、ポインタが高く評価されたことを認めます。
これは正解です。 @ AlexGがtypeofを使用する方法を試したところ、Typescriptは 'IPrimaryNavigationOpts'インターフェースを見つけることができなかった – Simon