继承Protractor的ElementFinder类型而不会收到打字稿警告

时间:2016-07-13 19:29:03

标签: typescript protractor

在打字稿中尝试使用量角器extend ElementFinder时,我收到了编译警告。

  

的package.json

"typescript": "^2.0.0-dev.20160707"
"typings": "^1.3.1"
"protractor": "3.3.0"

在我的项目中,我安装了typing definitions from definitely typed,到目前为止一切都很好。

但是,一旦我imported the ElementFinder class from protractor directly,它就开始引用built目录的element.d.ts文件来输入信息。出于某种原因,导出的输入信息表明,当源代码(甚至是生成的webdriver.Promise javascript中的文档!)表示类型为built/时,所有内容都返回webdriver.promise.Promise

我在此typescript file that represents a datepicker in our component library上收到以下编译警告。

node_modules/protractor/built/element.d.ts(58,31): error TS2305: Module 'webdriver' has no exported member 'Promise'.
node_modules/protractor/built/element.d.ts(60,106): error TS2305: Module 'webdriver' has no exported member 'Promise'.
node_modules/protractor/built/element.d.ts(222,24): error TS2305: Module 'webdriver' has no exported member 'Promise'.
node_modules/protractor/built/element.d.ts(255,36): error TS2305: Module 'webdriver' has no exported member 'Promise'.
node_modules/protractor/built/element.d.ts(280,54): error TS2305: Module 'webdriver' has no exported member 'Promise'.
node_modules/protractor/built/element.d.ts(303,35): error TS2305: Module 'webdriver' has no exported member 'Promise'.
node_modules/protractor/built/element.d.ts(336,37): error TS2305: Module 'webdriver' has no exported member 'Promise'.
node_modules/protractor/built/element.d.ts(368,62): error TS2305: Module 'webdriver' has no exported member 'Promise'.
node_modules/protractor/built/element.d.ts(642,37): error TS2305: Module 'webdriver' has no exported member 'Promise'.
node_modules/protractor/built/protractor.d.ts(96,22): error TS2305: Module 'webdriver' has no exported member 'Promise'.
node_modules/protractor/built/protractor.d.ts(201,57): error TS2305: Module 'webdriver' has no exported member 'Promise'.
node_modules/protractor/built/protractor.d.ts(214,57): error TS2305: Module 'webdriver' has no exported member 'Promise'.
node_modules/protractor/built/protractor.d.ts(221,93): error TS2305: Module 'webdriver' has no exported member 'Promise'.
node_modules/protractor/built/protractor.d.ts(313,41): error TS2305: Module 'webdriver' has no exported member 'Promise'.
node_modules/protractor/built/protractor.d.ts(322,36): error TS2305: Module 'webdriver' has no exported member 'Promise'.

这很奇怪,因为我看到我的rxDatePicker实例显示了ElementFinder的所有方法和属性,因此生成的javascript正在创建,我只是看到了很多警告。

也许有办法忽略这些警告?有没有办法做到这一点?

1 个答案:

答案 0 :(得分:1)

如果您没有找到它,这是临时解决方案:

在package.json中,确保此行为2.44。*   " @ types / selenium-webdriver":" 2.44。*",