Closed jleck closed 4 years ago
Hi. Thanks for submitting the issue. Unfortunately I was expecting this issue. I will take a look what can I do
Same issue currently with the last version.. :-( Can you fix the code with the @jleck solution please?
Hi @christophedebatz, if you add the types within this package as well as the standard types, it should work as is.
When you say "within this package", do you mean that I have to manually modify some file of my node_modules or another file I don't know about ? Thanks @jleck
HI @christophedebatz ,
In your tsconfig.json, add:
{
"compilerOptions": {
"typeRoots": [
"./node_modules/nightwatch-api/types",
"./node_modules/@types"
]
}
}
That will make it pick up the modified type definitions from this package. While I think it should be refactored so this isn't needed, it does work for now.
Thanks @jleck Do you had any other issues with the typings? For me yes, just take a look here: My code, very simple:
import { client } from 'nightwatch-api'
import { Given } from 'cucumber'
Given('I go to hozana.org', () => {
return client.assert.visible('input[name=jumbotron]')
})
And TS error:
src/features/homepage.ts:6:24 - error TS2339: Property 'visible' does not exist on type 'string | Function | Promise<Api> | Expect | Sections | Pages'.
Property 'visible' does not exist on type 'string'.
6 return client.assert.visible('input[name=jumbotron]')
~~~~~~~
Any idea?
Hi @christophedebatz ,
I'm using .waitForElementVisible('input[name=jumbotron]')
without issue, does that work for you?
P.S. I'm using this with cucumber too!
@christophedebatz actually just noticed, I'm always using through a page object too.
Hello @jleck thank you for replying quickly, Can you send me your conifgurations files please (tsc, cucumber and nightwatch), because I'm still encountering some types errors and the page object does not work with Typescript for me. We have the same goal: work with nightwatch and cucumber with typescript ! Thanks a lot,
@jleck
The waitForElementVisible
is working for me but all the client.assert.XXXX
assertions are not recognized by typescript linter? And you?
Idem, on my project, the page ares not found by nightwatch ... :(
@christophedebatz sorry for the delay, just seen this.
I don't seem to have any TS after loading those types. Although IMO I would use any for now, as the types don't really match what's actually available.
Hi,
I've just been trying to use the module within my typescript project, but the following lline from index.d.ts errors:
I can fix this by changing it to:
I did however look at your tsconfig, and note you load in your own type definitions. Might to be useful to document the need for setting
typeRoots
somewhere.