Skip to content

Commit 59d1e87

Browse files
author
Hyunje Jun
committed
Simplify type definition for Action
1 parent 4fde330 commit 59d1e87

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lib/types.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ export type FlexBox = {
260260

261261
export type FlexButton = {
262262
type: "button";
263-
action: Action<{ label: string }>;
263+
action: Action;
264264
flex?: number;
265265
margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
266266
height?: "sm" | "md";
@@ -325,7 +325,7 @@ export type FlexImage = {
325325
| "1:3";
326326
aspectMode?: "cover" | "fit";
327327
backgroundColor?: string;
328-
action?: Action<{ label: string }>;
328+
action?: Action;
329329
};
330330

331331
export type FlexSeparator = {
@@ -360,7 +360,7 @@ export type FlexText = {
360360
wrap?: boolean;
361361
weight?: "regular" | "bold";
362362
color?: string;
363-
action?: Action<{ label: string }>;
363+
action?: Action;
364364
};
365365

366366
export type TemplateContent =
@@ -377,13 +377,13 @@ export type TemplateButtons = {
377377
imageBackgroundColor?: string;
378378
title?: string;
379379
text: string;
380-
actions: Action<{ label: string }>[];
380+
actions: Action[];
381381
};
382382

383383
export type TemplateConfirm = {
384384
type: "confirm";
385385
text: string;
386-
actions: Action<{ label: string }>[];
386+
actions: Action[];
387387
};
388388

389389
export type TemplateCarousel = {
@@ -398,7 +398,7 @@ export type TemplateColumn = {
398398
imageBackgroundColor?: string;
399399
title?: string;
400400
text: string;
401-
actions: Action<{ label: string }>[];
401+
actions: Action[];
402402
};
403403

404404
export type TemplateImageCarousel = {
@@ -411,11 +411,12 @@ export type TemplateImageColumn = {
411411
action: Action<{ label?: string }>;
412412
};
413413

414-
export type Action<Label> =
415-
| PostbackAction & Label
416-
| MessageAction & Label
417-
| URIAction & Label
418-
| DatetimePickerAction & Label;
414+
export type Action<ExtraFields = { label: string }> = (
415+
| PostbackAction
416+
| MessageAction
417+
| URIAction
418+
| DatetimePickerAction) &
419+
ExtraFields;
419420

420421
export type PostbackAction = {
421422
type: "postback";

0 commit comments

Comments
 (0)