From b4253ea27647aac484ab92829cd716ec261d9e1a 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 | 25 +++++++------------ .../wdio-browserstack-service/src/index.ts | 16 ++++++++++++ 2 files changed, 25 insertions(+), 16 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 ff43c67d27a..050e4911c2a 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,17 +1,10 @@ -declare namespace WebdriverIO { - interface Browser { - getAccessibilityResultsSummary: () => Promise>, - getAccessibilityResults: () => Promise>>, - performScan: () => Promise | undefined>, - startA11yScanning: () => Promise, - stopA11yScanning: () => Promise - } +// The WebdriverIO.Browser / WebdriverIO.MultiRemoteBrowser augmentations for the +// accessibility methods (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. This file is intentionally left without those +// declarations; it is kept because src/accessibility-handler.ts and +// src/cli/modules/accessibilityModule.ts reference it via `/// `. - interface MultiRemoteBrowser { - getAccessibilityResultsSummary: () => Promise>, - getAccessibilityResults: () => Promise>>, - performScan: () => Promise | undefined>, - startA11yScanning: () => Promise, - stopA11yScanning: () => Promise - } -} +export {} 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 93f88bf93ab9cdfe9a2f5e5c1b920d772a8e613f 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 | 2 +- packages/wdio-browserstack-service/src/index.ts | 8 -------- 2 files changed, 1 insertion(+), 9 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 050e4911c2a..05d2d04f0ff 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,4 +1,4 @@ -// The WebdriverIO.Browser / WebdriverIO.MultiRemoteBrowser augmentations for the +// The WebdriverIO.Browser augmentation for the // accessibility methods (getAccessibilityResultsSummary, getAccessibilityResults, // performScan, startA11yScanning, stopA11yScanning) now live in src/index.ts inside // `declare global { namespace WebdriverIO { ... } }`, so that tsc emits them into 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 ee6aaa130015bc9095aa78974d0d06192fe4a91d Mon Sep 17 00:00:00 2001 From: Harshit Date: Mon, 29 Jun 2026 17:14:08 +0530 Subject: [PATCH 3/4] chore(wdio-browserstack-service): remove dead bstack-service-types.d.ts and its references 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 src/@types/bstack-service-types.d.ts exports nothing and its two `/// ` directives (accessibility-handler.ts, cli/modules/accessibilityModule.ts) are dead. Delete the file and remove the references. No type-surface change — build/index.d.ts still emits the 5 a11y methods on Browser. Co-Authored-By: Claude Opus 4.8 --- .../src/@types/bstack-service-types.d.ts | 10 ---------- .../src/accessibility-handler.ts | 1 - .../src/cli/modules/accessibilityModule.ts | 1 - 3 files changed, 12 deletions(-) delete mode 100644 packages/wdio-browserstack-service/src/@types/bstack-service-types.d.ts 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 deleted file mode 100644 index 05d2d04f0ff..00000000000 --- a/packages/wdio-browserstack-service/src/@types/bstack-service-types.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// The WebdriverIO.Browser augmentation for the -// accessibility methods (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. This file is intentionally left without those -// declarations; it is kept because src/accessibility-handler.ts and -// src/cli/modules/accessibilityModule.ts reference it via `/// `. - -export {} 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 94cd4dc49b4efa32f3b61ba09cec7e947a4860d9 Mon Sep 17 00:00:00 2001 From: Harshit Date: Mon, 29 Jun 2026 17:45:38 +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()) +})