From e476648c9aad09dc5ce3c2a944d23fe9f078de7b Mon Sep 17 00:00:00 2001 From: Clay Miller Date: Mon, 4 May 2020 12:20:23 -0400 Subject: [PATCH] Define 'SelectMenuItemProps' as a [discriminated union](https://www.typescriptlang.org/docs/handbook/advanced-types.html#discriminated-unions) --- index.d.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 7474a9a41fb..d89f1bba077 100644 --- a/index.d.ts +++ b/index.d.ts @@ -302,10 +302,16 @@ declare module '@primer/components' { export interface SelectMenuListProps extends CommonProps, Omit, 'color'> {} - export interface SelectMenuItemProps extends CommonProps, - Omit, 'color'> { - selected?: boolean + interface SelectMenuItemCommonProps extends CommonProps { + selected?: boolean; + } + interface SelectMenuItemAsButtonProps extends SelectMenuItemCommonProps, Omit, 'color'> { + as: "button" + } + interface SelectMenuItemAsAnchorProps extends SelectMenuItemCommonProps, Omit, 'color'> { + as: "a" } + export type SelectMenuItemProps = SelectMenuItemAsButtonProps | SelectMenuItemAsAnchorProps; export interface SelectMenuFooterProps extends CommonProps, Omit, 'color'> {}