Skip to content

chore: Enable strict TS mode#1064

Merged
mykola-mokhnach merged 3 commits into
appium:masterfrom
mykola-mokhnach:lint
May 9, 2026
Merged

chore: Enable strict TS mode#1064
mykola-mokhnach merged 3 commits into
appium:masterfrom
mykola-mokhnach:lint

Conversation

@mykola-mokhnach
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Enables TypeScript strict mode across the project and updates library code plus unit tests to satisfy stricter type-checking (including more accurate async stubbing and improved error handling).

Changes:

  • Turned on compilerOptions.strict in tsconfig.json and added missing type dependencies.
  • Updated driver/command modules for stricter typing (type-only imports, explicit this typing, improved error wrapping, tighter argument validation).
  • Updated unit tests to use typed variables and async-aware Sinon stubs (resolves/Promise.resolve) consistent with the underlying async APIs.

Reviewed changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tsconfig.json Enables strict TypeScript checking for lib and test.
package.json Updates dependencies and adds missing @types/* packages needed for strict-mode compilation.
lib/execute-method-map.ts Converts import to type-only to avoid runtime import when only types are needed.
lib/driver.ts Adjusts imports and class fields for strict property initialization; improves logcat-stop error message formatting.
lib/commands/types.ts Makes timing a type-only import used for type definitions.
lib/commands/system-bars.ts Wraps shell failures with an Error including a cause.
lib/commands/shell.ts Adds an explicit this: AndroidDriver annotation for stricter typing.
lib/commands/resources.ts Adds cause when rethrowing errors to preserve underlying failures.
lib/commands/recordscreen.ts Adds cause when rethrowing background-recording termination errors.
lib/commands/permissions.ts Adds validation to require appPackage before changing permissions.
lib/commands/performance.ts Adjusts typing for cpuinfo return shape and removes redundant parsing assignment.
lib/commands/network.ts Refactors service-selection logic to be more type-friendly under strict mode.
test/unit/commands/webview-helper-specs.ts Adds explicit string[] typing and makes shell stubs async-resolving.
test/unit/commands/recordscreen-specs.ts Uses resolves for async getApiLevel stub.
test/unit/commands/performance-specs.ts Makes stubs async-resolving and tightens stub typing for strict mode.
test/unit/commands/network-specs.ts Converts various ADB/driver stubs to async resolves and aligns expected types.
test/unit/commands/log-specs.ts Uses LogEntry typing and async getLogcatLogs stubbing.
test/unit/commands/lock-specs.ts Adds capability typing, converts relevant stubs to async, and adjusts helper typings for strict mode.
test/unit/commands/ime-specs.ts Converts ADB/driver stubs to async resolves where appropriate.
test/unit/commands/geolocation-specs.ts Converts ADB shell stub to async resolves.
test/unit/commands/file-actions-specs.ts Converts temp/fs/util stubs to async resolves to match awaited production code.
test/unit/commands/device-specs.ts Makes ADB.createADB stub async, and updates emulator-related stubs to async.
test/unit/commands/context-specs.ts Uses a real ADB instance, async stubs for helpers, and updates setupNewChromedriver calls to pass device id.
test/unit/commands/app-management-specs.ts Converts ADB/fs stubs to async resolves to match awaited production code.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +41 to +46
throw new Error(
`Cannot retrieve system bars details. Original error: ${(e as Error).message}`,
{
cause: e,
},
);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is ok

return true;
} catch (err) {
throw new Error(`Unable to stop the background screen recording: ${(err as Error).message}`);
throw new Error(`Unable to stop the background screen recording: ${(err as Error).message}`, {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is ok

Comment on lines 93 to 97
case 'batteryinfo':
return await getBatteryInfo.call(this, retries);
case 'cpuinfo':
return await getCPUInfo.call(this, packageName, retries);
return (await getCPUInfo.call(this, packageName, retries)) as any[][];
case 'memoryinfo':
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't want to change it as part of this PR

@mykola-mokhnach mykola-mokhnach merged commit f51578d into appium:master May 9, 2026
9 checks passed
@mykola-mokhnach mykola-mokhnach deleted the lint branch May 9, 2026 21:26
github-actions Bot pushed a commit that referenced this pull request May 9, 2026
## [13.2.2](v13.2.1...v13.2.2) (2026-05-09)

### Miscellaneous Chores

* Enable strict TS mode ([#1064](#1064)) ([f51578d](f51578d))
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

🎉 This PR is included in version 13.2.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants