Skip to content

Commit 9a71dc5

Browse files
authored
Correct flex text type def (#311)
1 parent 3c0b51b commit 9a71dc5

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

lib/types.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,14 +1529,8 @@ export type FlexSpacer = {
15291529
*/
15301530
size?: "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
15311531
};
1532-
1533-
export type FlexText = {
1532+
type FlexTextBase = {
15341533
type: "text";
1535-
text: string;
1536-
/**
1537-
* Array of spans. Be sure to set either one of the `text` property or `contents` property. If you set the `contents` property, `text` is ignored.
1538-
*/
1539-
contents?: FlexSpan[];
15401534
/**
15411535
* The method by which to adjust the text font size. Specify this value:
15421536
*
@@ -1659,7 +1653,23 @@ export type FlexText = {
16591653
* The default value is `none`.
16601654
*/
16611655
decoration?: string;
1662-
} & Offset;
1656+
}
1657+
1658+
type FlexTextWithText = FlexTextBase & {
1659+
text: string;
1660+
contents?: never;
1661+
}
1662+
1663+
type FlexTextWithContents = FlexTextBase & {
1664+
/**
1665+
* Array of spans. Be sure to set either one of the `text` property or `contents` property. If you set the `contents` property, `text` is ignored.
1666+
*/
1667+
contents: FlexSpan[];
1668+
text?: never;
1669+
}
1670+
1671+
export type FlexText = (FlexTextWithText | FlexTextWithContents) &
1672+
Offset;
16631673

16641674
/**
16651675
* This component renders multiple text strings with different designs in one row. You can specify the color, size, weight, and decoration for the font. Span is set to `contents` property in [Text](https://developers.line.biz/en/reference/messaging-api/#f-text).

0 commit comments

Comments
 (0)