Skip to content

Commit 12187c4

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
[cleanup] Types around ViewFunctionHelper
Bug: none Change-Id: I55cd01185cd811cf57b14da941a7d8a3f5546b87 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6351856 Commit-Queue: Nikolay Vitkov <[email protected]> Auto-Submit: Nikolay Vitkov <[email protected]> Commit-Queue: Alex Rudenko <[email protected]> Reviewed-by: Alex Rudenko <[email protected]>
1 parent df83fd1 commit 12187c4

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

front_end/testing/ViewFunctionHelpers.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import type * as Platform from '../core/platform/platform.js';
56
import type * as UI from '../ui/legacy/legacy.js';
67

7-
type WidgetConstructor = abstract new (...args: any[]) => UI.Widget.Widget|HTMLElement;
8+
type WidgetConstructor = Platform.Constructor.AbstractConstructor<UI.Widget.Widget|HTMLElement>;
89
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9-
type ViewFunctionLike = ((input: any, output: any, target: HTMLElement) => void);
10+
type ViewFunctionLike = (input: any, output: any, target: HTMLElement) => void;
1011

1112
type FindViewFunction<ParametersT extends readonly unknown[]> = ParametersT extends [infer Head, ...infer Tail] ?
1213
Head extends ViewFunctionLike ? Head : FindViewFunction<Tail>:
@@ -18,13 +19,9 @@ type ViewFunction<WidgetConstructorT extends WidgetConstructor> =
1819
type ViewFunctionParameters<WidgetConstructorT extends WidgetConstructor> =
1920
Parameters<ViewFunction<WidgetConstructorT>>;
2021

21-
export type ViewInput<WidgetConstructorT extends WidgetConstructor> =
22-
ViewFunctionParameters<WidgetConstructorT>[0];
22+
type ViewInput<WidgetConstructorT extends WidgetConstructor> = ViewFunctionParameters<WidgetConstructorT>[0];
2323

24-
export type ViewOutput<WidgetConstructorT extends WidgetConstructor> =
25-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
26-
{} extends ViewFunctionParameters<WidgetConstructorT>[1] ? never :
27-
ViewFunctionParameters<WidgetConstructorT>[1];
24+
type ViewOutput<WidgetConstructorT extends WidgetConstructor> = ViewFunctionParameters<WidgetConstructorT>[1];
2825

2926
interface ViewStubExtensions<WidgetConstructorT extends WidgetConstructor> {
3027
input: ViewInput<WidgetConstructorT>;
@@ -41,8 +38,9 @@ export type ViewFunctionStub<WidgetConstructorT extends WidgetConstructor> =
4138
ViewFunction<WidgetConstructorT>&ViewStubExtensions<WidgetConstructorT>;
4239

4340
export function createViewFunctionStub<WidgetConstructorT extends WidgetConstructor>(
44-
constructor: WidgetConstructorT,
45-
outputValues?: ViewOutput<WidgetConstructorT>): ViewFunctionStub<WidgetConstructorT> {
41+
_constructor: WidgetConstructorT,
42+
outputValues?: ViewOutput<WidgetConstructorT>,
43+
): ViewFunctionStub<WidgetConstructorT> {
4644
const result: InternalViewStubExtensions<WidgetConstructorT> =
4745
((input: ViewInput<WidgetConstructorT>, output: ViewOutput<WidgetConstructorT>, _target: HTMLElement) => {
4846
++result.callCount;

0 commit comments

Comments
 (0)