From dc743a0571260ce0d3b93f77c93bc7eac188e500 Mon Sep 17 00:00:00 2001 From: Harshit Date: Mon, 29 Jun 2026 11:52:40 +0530 Subject: [PATCH 1/4] fix(wdio-browserstack-service): ship a11y Browser type augmentations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The accessibility methods (startA11yScanning, stopA11yScanning, performScan, getAccessibilityResults, getAccessibilityResultsSummary) are attached to the `browser` object at runtime, but their TypeScript declarations lived only in src/@types/bstack-service-types.d.ts — a bare `declare namespace WebdriverIO` ambient file that tsc never emits into the published build/index.d.ts. Consumers therefore hit `Property 'startA11yScanning' does not exist on type 'Browser'` even though the methods work at runtime (tests run; only tsc/lint fails). Move the Browser / MultiRemoteBrowser augmentations into the existing `declare global { namespace WebdriverIO { ... } }` block in src/index.ts (mirroring the ServiceOption augmentation already there), so they compile into the published types and reach consumers. Empty the now-duplicate body in the ambient .d.ts to avoid a duplicate-identifier conflict. Verified: a minimal consumer tsc goes from 5 TS2339 errors to 0, and the 5 methods now appear on Browser + MultiRemoteBrowser in build/index.d.ts. Co-Authored-By: Claude Opus 4.8 --- .../src/@types/bstack-service-types.d.ts | 17 +++++++---------- packages/wdio-browserstack-service/src/index.ts | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/packages/wdio-browserstack-service/src/@types/bstack-service-types.d.ts b/packages/wdio-browserstack-service/src/@types/bstack-service-types.d.ts index 5e5becd1764..4012ae9b727 100644 --- a/packages/wdio-browserstack-service/src/@types/bstack-service-types.d.ts +++ b/packages/wdio-browserstack-service/src/@types/bstack-service-types.d.ts @@ -1,19 +1,16 @@ +// The WebdriverIO.Browser / WebdriverIO.MultiRemoteBrowser accessibility +// augmentations (getAccessibilityResultsSummary, getAccessibilityResults, +// performScan, startA11yScanning, stopA11yScanning) now live in src/index.ts +// inside `declare global { namespace WebdriverIO { ... } }`, so that tsc emits +// them into build/index.d.ts for consumers. They were moved out of this ambient +// file to avoid duplicate-declaration conflicts. The setCustomTags augmentation +// stays here (it is not part of the a11y type-shipping fix). declare namespace WebdriverIO { interface Browser { - getAccessibilityResultsSummary: () => Promise>, - getAccessibilityResults: () => Promise>>, - performScan: () => Promise | undefined>, - startA11yScanning: () => Promise, - stopA11yScanning: () => Promise, setCustomTags: (key: string, value: string) => Promise } interface MultiRemoteBrowser { - getAccessibilityResultsSummary: () => Promise>, - getAccessibilityResults: () => Promise>>, - performScan: () => Promise | undefined>, - startA11yScanning: () => Promise, - stopA11yScanning: () => Promise, setCustomTags: (key: string, value: string) => Promise } } diff --git a/packages/wdio-browserstack-service/src/index.ts b/packages/wdio-browserstack-service/src/index.ts index 32b65e41f1a..b8e61d6c4eb 100644 --- a/packages/wdio-browserstack-service/src/index.ts +++ b/packages/wdio-browserstack-service/src/index.ts @@ -20,6 +20,22 @@ export * from './types.js' declare global { namespace WebdriverIO { interface ServiceOption extends BrowserstackConfig {} + + interface Browser { + getAccessibilityResultsSummary: () => Promise>, + getAccessibilityResults: () => Promise>>, + performScan: () => Promise | undefined>, + startA11yScanning: () => Promise, + stopA11yScanning: () => Promise + } + + interface MultiRemoteBrowser { + getAccessibilityResultsSummary: () => Promise>, + getAccessibilityResults: () => Promise>>, + performScan: () => Promise | undefined>, + startA11yScanning: () => Promise, + stopA11yScanning: () => Promise + } } interface State { value: number, From d19635d2ad63ebe9dd6e37e8e9e666c77619951e Mon Sep 17 00:00:00 2001 From: Harshit Date: Mon, 29 Jun 2026 15:17:48 +0530 Subject: [PATCH 2/4] fix(wdio-browserstack-service): drop MultiRemoteBrowser a11y augmentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verification found a runtime gap: the service attaches the 5 a11y methods to a single Browser object only (accessibility-handler.ts:192/:226), with no multiremote instance iteration — unlike the multiremote handling at service.ts:664+. The CLI a11y path is also disabled for multiremote (launcher.ts:316). So declaring the methods on MultiRemoteBrowser would type-check calls that are `undefined` at runtime. Drop the MultiRemoteBrowser augmentation so the published type matches actual runtime support; multiremote a11y runtime attachment is a separate follow-up. Browser augmentation is unchanged. Co-Authored-By: Claude Opus 4.8 --- .../src/@types/bstack-service-types.d.ts | 10 +++++----- packages/wdio-browserstack-service/src/index.ts | 8 -------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/wdio-browserstack-service/src/@types/bstack-service-types.d.ts b/packages/wdio-browserstack-service/src/@types/bstack-service-types.d.ts index 4012ae9b727..1ae813fc350 100644 --- a/packages/wdio-browserstack-service/src/@types/bstack-service-types.d.ts +++ b/packages/wdio-browserstack-service/src/@types/bstack-service-types.d.ts @@ -1,8 +1,8 @@ -// The WebdriverIO.Browser / WebdriverIO.MultiRemoteBrowser accessibility -// augmentations (getAccessibilityResultsSummary, getAccessibilityResults, -// performScan, startA11yScanning, stopA11yScanning) now live in src/index.ts -// inside `declare global { namespace WebdriverIO { ... } }`, so that tsc emits -// them into build/index.d.ts for consumers. They were moved out of this ambient +// The WebdriverIO.Browser accessibility augmentations +// (getAccessibilityResultsSummary, getAccessibilityResults, performScan, +// startA11yScanning, stopA11yScanning) now live in src/index.ts inside +// `declare global { namespace WebdriverIO { ... } }`, so that tsc emits them +// into build/index.d.ts for consumers. They were moved out of this ambient // file to avoid duplicate-declaration conflicts. The setCustomTags augmentation // stays here (it is not part of the a11y type-shipping fix). declare namespace WebdriverIO { diff --git a/packages/wdio-browserstack-service/src/index.ts b/packages/wdio-browserstack-service/src/index.ts index b8e61d6c4eb..1c9ca3e1fef 100644 --- a/packages/wdio-browserstack-service/src/index.ts +++ b/packages/wdio-browserstack-service/src/index.ts @@ -28,14 +28,6 @@ declare global { startA11yScanning: () => Promise, stopA11yScanning: () => Promise } - - interface MultiRemoteBrowser { - getAccessibilityResultsSummary: () => Promise>, - getAccessibilityResults: () => Promise>>, - performScan: () => Promise | undefined>, - startA11yScanning: () => Promise, - stopA11yScanning: () => Promise - } } interface State { value: number, From 9faffb6bdb729a7aec3e1110952fc6a3406f9f99 Mon Sep 17 00:00:00 2001 From: Harshit Date: Thu, 9 Jul 2026 19:20:16 +0530 Subject: [PATCH 3/4] chore(wdio-browserstack-service): drop dead a11y /// directives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The a11y Browser type augmentation now lives in src/index.ts inside `declare global { namespace WebdriverIO { ... } }`, so the two `/// ` directives in accessibility-handler.ts and cli/modules/accessibilityModule.ts are dead — the a11y types are visible globally without them. The ambient file itself is kept: it still declares the unrelated setCustomTags augmentation. Co-Authored-By: Claude Opus 4.8 --- packages/wdio-browserstack-service/src/accessibility-handler.ts | 1 - .../src/cli/modules/accessibilityModule.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/wdio-browserstack-service/src/accessibility-handler.ts b/packages/wdio-browserstack-service/src/accessibility-handler.ts index 76ae8329cc0..ff1ef903935 100644 --- a/packages/wdio-browserstack-service/src/accessibility-handler.ts +++ b/packages/wdio-browserstack-service/src/accessibility-handler.ts @@ -1,4 +1,3 @@ -/// import util from 'node:util' import type { Capabilities, Frameworks, Options } from '@wdio/types' diff --git a/packages/wdio-browserstack-service/src/cli/modules/accessibilityModule.ts b/packages/wdio-browserstack-service/src/cli/modules/accessibilityModule.ts index d71be0fe25c..1ad0d37159e 100644 --- a/packages/wdio-browserstack-service/src/cli/modules/accessibilityModule.ts +++ b/packages/wdio-browserstack-service/src/cli/modules/accessibilityModule.ts @@ -1,4 +1,3 @@ -/// import BaseModule from './baseModule.js' import { BrowserstackCLI } from '../index.js' import { BStackLogger } from '../cliLogger.js' From 3466c609a8830481c9a8ef2021064e0851fefa18 Mon Sep 17 00:00:00 2001 From: Harshit Date: Thu, 9 Jul 2026 19:20:16 +0530 Subject: [PATCH 4/4] test(wdio-browserstack-service): guard a11y Browser type augmentation Add a type-level test asserting the 5 accessibility methods (startA11yScanning, stopA11yScanning, performScan, getAccessibilityResults, getAccessibilityResultsSummary) are typed on WebdriverIO.Browser. These declarations previously lived in an un-emitted ambient file and silently never reached consumers; this test fails if the published augmentation ever regresses again. Co-Authored-By: Claude Opus 4.8 --- .../webdriverio/browserstackService.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/typings/webdriverio/browserstackService.ts diff --git a/tests/typings/webdriverio/browserstackService.ts b/tests/typings/webdriverio/browserstackService.ts new file mode 100644 index 00000000000..2657f017ac0 --- /dev/null +++ b/tests/typings/webdriverio/browserstackService.ts @@ -0,0 +1,30 @@ +import { expectType } from 'tsd' +import { browser } from '@wdio/globals' + +/** + * Regression guard for the @wdio/browserstack-service accessibility + * augmentation of WebdriverIO.Browser. + * + * These five methods are declared inside + * declare global { namespace WebdriverIO { interface Browser { ... } } } + * in packages/wdio-browserstack-service/src/index.ts. They previously lived + * in an un-emitted ambient .d.ts file and silently never reached the published + * build/index.d.ts, so consumers lost the typings. This file pulls in the + * published @wdio/browserstack-service types (it is listed in this suite's + * tsconfig.json `types` array) and fails `test:typings:webdriverio` if any of + * the five methods ever stops being typed on WebdriverIO.Browser again. + */ +;(async () => { + expectType<() => Promise>>(browser.getAccessibilityResultsSummary) + expectType<() => Promise>>>(browser.getAccessibilityResults) + expectType<() => Promise | undefined>>(browser.performScan) + expectType<() => Promise>(browser.startA11yScanning) + expectType<() => Promise>(browser.stopA11yScanning) + + // also assert the call-site return types resolve as declared + expectType>(await browser.getAccessibilityResultsSummary()) + expectType>>(await browser.getAccessibilityResults()) + expectType | undefined>(await browser.performScan()) + expectType(await browser.startA11yScanning()) + expectType(await browser.stopA11yScanning()) +})