Skip to content

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

Open
harshit-browserstack wants to merge 1 commit into
mainfrom
fix/sdk-6882-wdio-setcustomtags-type
Open

fix(browserstack-service): declare browser.setCustomTags on WebdriverIO.Browser type (SDK-6882)#5
harshit-browserstack wants to merge 1 commit into
mainfrom
fix/sdk-6882-wdio-setcustomtags-type

Conversation

@harshit-browserstack

Copy link
Copy Markdown
Owner

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 WebdriverIO.Browser augmentation.

Fix

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

interface Browser {
    setCustomTags: (key: string, value: string) => Promise<void>
}

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

Verification

  • Pristine published @wdio/browserstack-service@9.29.1tsc reproduces the exact TS2339 (exit 2).
  • With this change built (pnpm build, exit 0), the regenerated build/index.d.ts emits the interface Browser { setCustomTags } augmentation; the same minimal project then compiles clean (tsc exit 0).
  • 0 TS errors; no duplicate-identifier conflict. Runtime behavior unchanged.

Scope / follow-up

Scoped to setCustomTags (the reported symptom). The a11y methods (getAccessibilityResults, performScan, …) share the same non-shipping cause and remain untyped for consumers — a follow-up could wire the full bstack-service-types.d.ts (incl. MultiRemoteBrowser) into the shipped types.

🤖 Generated with Claude Code

…IO.Browser type (SDK-6882)

`browser.setCustomTags(key, value)` is attached at runtime by the service but
was not declared on the global `WebdriverIO.Browser` interface in the shipped
type entry (`build/index.d.ts`). The existing declaration in
`src/@types/bstack-service-types.d.ts` reaches only internal source via
`/// <reference path>` and is never emitted to consumers, so TypeScript users
got: `Property 'setCustomTags' does not exist on type 'Browser'.`

Add the augmentation to the `declare global { namespace WebdriverIO {} }` block
in `src/index.ts`, which is emitted to `build/index.d.ts` and delivered to
consumers. Verified: pristine 9.29.1 reproduces the exact TS2339; with this
change built, `tsc` compiles clean (exit 0). Runtime behavior unchanged.

Co-Authored-By: Claude Opus 4.8 <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.

2 participants