Skip to content

fix: declare browser.setCustomTags on WebdriverIO.Browser type (SDK-6882)#53

Open
Bhargavi-BS wants to merge 2 commits into
mainfrom
fix/sdk-6882-wdio-setcustomtags-type
Open

fix: declare browser.setCustomTags on WebdriverIO.Browser type (SDK-6882)#53
Bhargavi-BS wants to merge 2 commits into
mainfrom
fix/sdk-6882-wdio-setcustomtags-type

Conversation

@Bhargavi-BS

@Bhargavi-BS Bhargavi-BS commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Port of harshit-browserstack/webdriverio#5 to the standalone repo.

What

Declares browser.setCustomTags(key, value) on the global WebdriverIO.Browser interface so TypeScript consumers of @wdio/browserstack-service can call it without a compile error.

Why

Jira SDK-6882: a WebdriverIO + Mocha (TypeScript) customer on @wdio/browserstack-service@9.29.1 hit:

Property 'setCustomTags' does not exist on type 'Browser'.

The command works at runtime (the service attaches it, and the customer's test calling it passed) — the failure is compile-time only. The setCustomTags/a11y declarations live in src/@types/bstack-service-types.d.ts but that file uses declare namespace and is pulled in only via /// <reference path> from internal source, so it is never emitted into the shipped build/index.d.ts (the package types entry). Consumers therefore receive no setCustomTags on WebdriverIO.Browser.

Fix

Add setCustomTags to the WebdriverIO.Browser augmentation in the declare global block of src/index.ts, which is emitted to build/index.d.ts and delivered to consumers:

setCustomTags: (key: string, value: string) => Promise<void>

Merges cleanly with the existing ambient declaration (identical signature). Runtime behavior unchanged.

Port notes (drift vs the fork PR)

The fork PR was authored against webdriverio/webdriverio@main, where the declare global block has no interface Browser, so it added a new one. This repo's main already ships an interface Browser augmentation in src/index.ts (the a11y methods — getAccessibilityResultsSummary, getAccessibilityResults, performScan, startA11yScanning, stopA11yScanning), so the setCustomTags member is added to that existing block instead of declaring a second one. This also means the fork PR's noted follow-up ("the a11y methods share the same non-shipping cause") is already addressed in this repo for those methods.

Verification

  • npx tsc --noEmit -p packages/browserstack-service exits 0 (after npm run generate) — no duplicate-identifier conflict with the ambient bstack-service-types.d.ts declaration.
  • Full vitest suite in packages/browserstack-service: 1004 passed / 0 failed (identical to base main — type-only change).
  • On the original fork PR, a minimal consumer project reproduced the exact TS2339 against the pristine published 9.29.1 tgz and compiled clean against the patched build.

🤖 Generated with Claude Code

…882)

Port of harshit-browserstack/webdriverio#5 to the standalone repo.

The command works at runtime but TypeScript consumers hit TS2339
because the declaration lives only in src/@types/bstack-service-types.d.ts,
which is never emitted into the shipped build/index.d.ts. Adding it to
the declare global block in src/index.ts ships the augmentation to
consumers. No runtime change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Bhargavi-BS
Bhargavi-BS requested a review from a team as a code owner July 16, 2026 12:30
xxshubhamxx
xxshubhamxx previously approved these changes Jul 16, 2026
Comment thread .changeset/fix-sdk-6882-setcustomtags-type.md Outdated
@dandonarahul2002

Copy link
Copy Markdown
Collaborator

rest lgtm

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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