Skip to content

Commit ecb36ec

Browse files
committed
Remove more useless types and generics
1 parent 847fcb0 commit ecb36ec

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/approval/ApprovalController.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,14 @@ const controllerName = 'ApprovalController';
1010
type ApprovalPromiseResolve = (value?: unknown) => void;
1111
type ApprovalPromiseReject = (error?: Error) => void;
1212

13-
type ApprovalRequestData = Record<string, unknown> | null;
13+
type ApprovalRequestData = Record<string, Json> | null;
1414

15-
interface ApprovalCallbacks {
15+
type ApprovalCallbacks = {
1616
resolve: ApprovalPromiseResolve;
1717
reject: ApprovalPromiseReject;
18-
}
18+
};
1919

20-
export type ApprovalRequest<
21-
Type extends string,
22-
RequestData extends ApprovalRequestData
23-
> = {
20+
export type ApprovalRequest<RequestData extends ApprovalRequestData> = {
2421
/**
2522
* The ID of the approval request.
2623
*/
@@ -39,7 +36,7 @@ export type ApprovalRequest<
3936
/**
4037
* The type of the approval request.
4138
*/
42-
type: Type;
39+
type: string;
4340

4441
/**
4542
* Additional data associated with the request.
@@ -51,10 +48,7 @@ export type ApprovalRequest<
5148
type ShowApprovalRequest = () => void | Promise<void>;
5249

5350
export type ApprovalControllerState = {
54-
pendingApprovals: Record<
55-
string,
56-
ApprovalRequest<string, Record<string, Json>>
57-
>;
51+
pendingApprovals: Record<string, ApprovalRequest<Record<string, Json>>>;
5852
pendingApprovalCount: number;
5953
};
6054

@@ -274,7 +268,7 @@ export class ApprovalController extends BaseController<
274268
* @param id - The id of the approval request.
275269
* @returns The approval request data associated with the id.
276270
*/
277-
get(id: string): ApprovalRequest<string, ApprovalRequestData> | undefined {
271+
get(id: string): ApprovalRequest<ApprovalRequestData> | undefined {
278272
return this.state.pendingApprovals[id];
279273
}
280274

@@ -553,7 +547,7 @@ export class ApprovalController extends BaseController<
553547
type: string,
554548
requestData?: Record<string, Json>,
555549
): void {
556-
const approval: ApprovalRequest<string, Record<string, Json> | null> = {
550+
const approval: ApprovalRequest<Record<string, Json> | null> = {
557551
id,
558552
origin,
559553
type,
@@ -562,6 +556,7 @@ export class ApprovalController extends BaseController<
562556
};
563557

564558
this.update((draftState) => {
559+
// Typecast: ts(2589)
565560
draftState.pendingApprovals[id] = approval as any;
566561
draftState.pendingApprovalCount = Object.keys(
567562
draftState.pendingApprovals,

0 commit comments

Comments
 (0)