Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/devsupport/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type ChildrenWithProps<Props> = ChildrenProp<ReactElement<Props>>;
* https://github.com/microsoft/TypeScript/issues/29729#issuecomment-505826972
*/
// eslint-disable-next-line @typescript-eslint/ban-types
export type LiteralUnion<T extends U, U = string> = T | (U & {});
export type LiteralUnion<T extends U, U = string> = T | (string & {});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 @mi5ha,

This won't work in the case you wanna change U to number for example (there you should get a type error).
image

So I think changing this type to the following would be more correct, as you then get ts errors in the numbers case, while also receiving auto-completion hints.

type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);

image
image


export type EvaStatus = LiteralUnion<'basic' | 'primary' | 'success' | 'info' | 'warning' | 'danger' | 'control'>;
export type EvaSize = LiteralUnion<'tiny' | 'small' | 'medium' | 'large' | 'giant'>;
Expand Down