Skip to content
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

feat(appium): generate declaration files #16597

Merged
merged 6 commits into from Mar 25, 2022
Merged

Conversation

boneskull
Copy link
Contributor

Configure TS to generate declaration files for appium package.

Most of these changes are just types getting added or changed via docstrings; in other places, typechecking has caught problems and I had to refactor code to address them.

  • Removed // @ts-check pragma from all files in lib/, since now checkJs: true is in tsconfig.json. It needs to stay in place elsewhere (I think) because only sources in lib have declarations generated.
  • The install, uninstall, update and run functions in the base ExtensionCommand class were renamed and prefixed with a _; TS does not allow overridden functions with differing signatures. It no longer exports a default.
  • Removed type prop of options for DriverCommand and PluginCommand constructors, respectively (this value is derived from the ExtensionConfig config parameter instead)
  • AppiumDriver now extends DriverCore instead of BaseDriver, since some of its function signatures differ from BaseDriver's.
  • Small refactor of deleteSession to make typechecker happy.
  • executeCommand now calls to BaseDriver directly if isUmbrellaCmd is truthy. This is one place where inheritance just kind of breaks, since BaseDriver#executeCommand returns something entirely different than AppiumDriver#executeCommand would otherwise.
  • Removed --delete-dir-on-start from build command, since it may blast generated declarations.

@boneskull
Copy link
Contributor Author

boneskull commented Mar 16, 2022

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@boneskull boneskull marked this pull request as draft March 18, 2022 18:16
@boneskull boneskull force-pushed the boneskull/types-3 branch 2 times, most recently from 1f75e4b to d0a294b Compare March 18, 2022 22:13
@boneskull boneskull marked this pull request as ready for review March 18, 2022 23:05
packages/appium/lib/appium.js Outdated Show resolved Hide resolved
packages/appium/lib/appium.js Show resolved Hide resolved
packages/appium/lib/cli/extension-command.js Outdated Show resolved Hide resolved
packages/appium/lib/cli/extension-command.js Outdated Show resolved Hide resolved
packages/appium/lib/cli/extension.js Outdated Show resolved Hide resolved
packages/appium/lib/main.js Outdated Show resolved Hide resolved
packages/appium/lib/utils.js Show resolved Hide resolved
packages/appium/types/cli.d.ts Show resolved Hide resolved
packages/appium/types/cli.d.ts Outdated Show resolved Hide resolved
@boneskull
Copy link
Contributor Author

this is failing b/c I changed something I thought was safe to change, but it wasn't.

@boneskull boneskull force-pushed the boneskull/types-4 branch 3 times, most recently from 5290ffc to db83065 Compare March 23, 2022 00:41
packages/appium/lib/cli/extension-command.js Outdated Show resolved Hide resolved
boneskull added a commit that referenced this pull request Mar 25, 2022
* feat(appium): generate declaration files

Configure TS to generate declaration files for `appium` package.

Most of these changes are just types getting added or changed via docstrings; in other places, typechecking has caught problems and I had to refactor code to address them.

- Removed `// @ts-check` pragma from all files in `lib/`, since now `checkJs: true` is in `tsconfig.json`.  It needs to stay in place elsewhere (I think) because only sources in `lib` have declarations generated.
- The `install`, `uninstall`, `update` and `run` functions in the base `ExtensionCommand` class were renamed and prefixed with a `_`; TS does not allow overridden functions with differing signatures.   It no longer exports a default.
- Removed `type` prop of options for `DriverCommand` and `PluginCommand` constructors, respectively (this value is derived from the `ExtensionConfig` `config` parameter instead)
- `AppiumDriver` now extends `DriverCore` instead of `BaseDriver`, since some of its function signatures differ from `BaseDriver`'s.
- Small refactor of `deleteSession` to make typechecker happy.
- `executeCommand` now calls to `BaseDriver` directly if `isUmbrellaCmd` is truthy.  This is one place where inheritance just kind of breaks, since `BaseDriver#executeCommand` returns something entirely different than `AppiumDriver#executeCommand` would otherwise.
- Removed `--delete-dir-on-start` from build command, since it may blast generated declarations.
- Reorganize declarations in `types/`; moved some of them out of `@typedef`s. `types.d.ts` becomes `index.d.ts`
- Note that this contains the declarations for `PluginClass` and `DriverClass`, which correspond to the types of extension "main" classes. This differs from the interfaces provided in `@appium/types` (e.g., `Driver`, `ExternalDriver`) in that these aren't just objects; they are classes with constructors and static members. I may end up moving some of this stuff into `@appium/types`, but I'm not sure how useful it will be.  Will see when I add types to `@appium/fake-driver`.

* chore(appium): remove transpile directives
this was ostensibly for gulp-babel

* chore(appium): remove redundant type declaration

* fix(appium): avoid potential unhandled rejections

- make types more readable

* chore(appium): fix capabilities types

- move `scripts/generate*` elsewhere
- add reference to `@appium/types` in `tsconfig.json`

* chore(appium): review updates for legibility
This was referenced Jun 15, 2022
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.

None yet

2 participants