【发布时间】:2017-12-03 01:06:42
【问题描述】:
我对此有些陌生。所以,如果我弄错了,请原谅我。 我试图这样做是为了在量角器 ElementFinder 类原型上定义一个方法。
我在这里遵循合并拉取请求中的语法。https://github.com/Microsoft/TypeScript/pull/6213
> 1 import { ElementFinder} from "protractor";
> 2
> 3 declare module "protractor" {
> 4 interface ElementFinder {
> 5 doSomething(): void;
> 6 } }
> 7
> 8
> 9 ElementFinder.prototype.doSomething = function (): void {
> 10 console.log("");
> 11 };
我在第 9 行收到此错误
[ts] 'ElementFinder' 仅指一种类型,但被用作 这里的值。
我在这里做错了什么?示例中唯一不同的是,我使用的是来自 npm 的模块,而不是在我的包中定义的模块。难道不能以这种方式扩充模块吗?
【问题讨论】:
标签: angular typescript protractor