From ef75066c4cec3ab59f2bd09144d9e4c1727b2f19 Mon Sep 17 00:00:00 2001 From: Roman Kuznetsov Date: Tue, 26 Mar 2024 15:17:44 +0300 Subject: [PATCH] fix: remove internal func typings from overwriteCommand --- src/browser/types.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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,