Skip to content

Commit

Permalink
[PR feedback] Types - is predicate rather than as casting
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Aug 6, 2024
1 parent e3c779a commit 1ffb335
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,15 @@ const renderOptionMeta = ({
);
}

const hasMetaTypeStyles = (
metaType: string
): metaType is keyof typeof styles.metaTypes =>
metaType in styles.metaTypes;

const cssStyles = [
styles.euiSelectableTemplateSitewide__optionMeta,
...(meta.type && meta.type in styles.metaTypes
? [
styles.metaTypes.fontWeight,
styles.metaTypes[meta.type as keyof typeof styles.metaTypes],
]
...(meta.type && hasMetaTypeStyles(meta.type)
? [styles.metaTypes.fontWeight, styles.metaTypes[meta.type]]
: []),
];

Expand Down

0 comments on commit 1ffb335

Please sign in to comment.