Skip to content Skip to sidebar Skip to footer

Migrating To Typescript. Why Is My Function Not Recognised?

I am trying to migrate a working JavaScript project to TypeScript. The project uses nightwatch.js This is my main test class: declare function require(path: string): any; import *

Solution 1:

this code is still very much JS/ES5 and not so much TS. Try to change import signinPage into import * as signinPage. Maybe that helps.

But really I recommend looking up ES6 / TS functionalities like classes. So make signinPage.ts:

export default class signinPage {
  signin(email, password) {
    return this
      .waitForElementVisible('@emailInput')
      .setValue('@emailInput', email)
      .setValue('@passwordInput', password)
      .waitForElementVisible('@signinButton')
      .click('@signinButton')
  }
  get elements() {
    return {
      emailInput: {
        selector: 'input[type=email]'
      },
      passwordInput: {
        selector: 'input[name=password]'
      },
      signinButton: {
        selector: 'button[type=submit]'
      }
    }
  }
}

and then change your import to import singinPage from "../src/pages/signinPage"

so you're pointing from TS file to another TS file, but you dont need the .ts extention.

Post a Comment for "Migrating To Typescript. Why Is My Function Not Recognised?"