Reputation: 5574
I am using protractor 4.x
with TypeScript. Using TypeScript 2.0
, the compiler complains in the following test:
it('should have url', done=>{
browser.getCurrentUrl().then((x)=>{
// do something with x
})
})
It is saying: error TS7006: Parameter 'x' implicitly has an 'any' type.
Yes, I know I can turn this off in the file, the tsconfig.json
or explicitly set the typ, but my real question is why?
When I hover over browser.getCurrentUrl()
it clearly says (property) Webdriver.getCurrentUrl: () => webdriver.promise.Promise<string>
so, x should implicitly be of type string
https://github.com/angular/protractor
noImplicitAny
to true
in tsconfig.json
spec.ts
filetsconfig.json
(straight from Protractor):
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": false,
"declaration": false,
"noImplicitAny": true,
"outDir": "tmp",
"types": ["node", "jasmine"]
},
"exclude": [
"node_modules",
"asyncAwait",
"plugins.ts"
]
}
Upvotes: 3
Views: 1757
Reputation: 10665
The reason for this is because you need to explicitly give a type to the parameter x
:
it('should have url', done=>{
browser.getCurrentUrl().then((x: string)=>{
// do something with x
})
})
Upvotes: 1