diff --git a/src/browser/types.ts b/src/browser/types.ts index 89671df25..4c507b5ad 100644 --- a/src/browser/types.ts +++ b/src/browser/types.ts @@ -1,3 +1,4 @@ +import type { EventEmitter } from "events"; import type { AssertViewCommand, AssertViewElementCommand } from "./commands/types"; import type { BrowserConfig } from "./../config/browser-config"; import type { AssertViewResult, RunnerTest, RunnerHook } from "../types"; @@ -17,15 +18,22 @@ export interface Browser { applyState: (state: Record) => void; } -type FunctionProperties = keyof T & +type FunctionProperties = Exclude< { // eslint-disable-next-line @typescript-eslint/no-explicit-any [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never; - }[keyof T]; + }[keyof T], + undefined +>; + +type EventEmitterMethod = FunctionProperties; declare global { // eslint-disable-next-line @typescript-eslint/no-namespace namespace WebdriverIO { + type BrowserCommand = Exclude, EventEmitterMethod>; + type ElementCommand = Exclude, EventEmitterMethod>; + interface Browser { getMeta(this: WebdriverIO.Browser): Promise; getMeta(this: WebdriverIO.Browser, key: string): Promise; @@ -36,7 +44,7 @@ declare global { getConfig(this: WebdriverIO.Browser): Promise; - overwriteCommand>( + overwriteCommand( name: CommandName, func: WebdriverIO.Browser[CommandName], attachToElement?: false, @@ -44,7 +52,7 @@ declare global { instances?: Record, ): void; - overwriteCommand>( + overwriteCommand( name: CommandName, func: WebdriverIO.Element[CommandName], attachToElement: true,