Skip to content

Typescript take two #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 66 commits into from
Oct 16, 2023
Merged

Typescript take two #488

merged 66 commits into from
Oct 16, 2023

Conversation

RickiJay-WMDE
Copy link
Member

@RickiJay-WMDE RickiJay-WMDE commented Oct 10, 2023

Typescript

Where possible, explicit type annotations were added to functions and ambiguously typed variables. Some custom types were defined based on apparent usage; WebDriverIO.Browser was extended to reflect the commands added in default-functions.ts. Configuration files were also changed to Typescript, and deepmerge-ts removed as an explicit dependency (though it remains an implicit one).

getElementByURI

Previously returned [] if a binding with the requested uri was not found. null was easier to check against when actually using the function in queryservice-post-upgrade tests.

editPage

editPage in default-functions.ts is the only place where a submit() method is used directly on a WebDriverIO.Element, which needed to be extended to include a submit() property (though as far as I can tell we aren't defining the method). Additionally, it included a browser.execute() call that passed this as a second parameter. Typescript complained that browser.execute() expected only 1 parameter, so I removed the this. Everything still seems to work.

Custom Types

  • Binding: returned by queryBlazeGraphItem
  • BotResponse: returned by deleteClaim
  • DatabaseConfig: parameter for dbQuery
  • ExternalChange: parameter and return type for getDispatchedExternalChange
  • LuaCPUValue: returned by getLuaCpuTime
  • TestResult and ResultType: used by JsonReporter

skipIfExtensionNotPresent

Most of our tests are written with () => {} format, while skipIfExtensionNotPresent explicitly requires function () {} format. Additionally, I couldn't find a spec file that used skipIfExtensionNotPresent on only one test of several, so I rearranged the spec files to use skipIfExtensionNotPresent in a beforeEach hook rather than in each test. The exception is special-version.ts, which checks against each extension in turn.

@RickiJay-WMDE RickiJay-WMDE marked this pull request as ready for review October 11, 2023 07:47
@RickiJay-WMDE RickiJay-WMDE requested a review from a team October 11, 2023 07:47
Copy link
Contributor

@lorenjohnson lorenjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and tested locally. Everything is happy 🎉

@RickiJay-WMDE RickiJay-WMDE merged commit 575ce48 into main Oct 16, 2023
@RickiJay-WMDE RickiJay-WMDE deleted the typescript-take-two branch October 16, 2023 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants