-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Feature request
Overview
Use of enums is generally discouraged in typescript because they don't exist natively in javascript and have some weird runtime behaviour. You can find many videos on youtube explaining why we should avoid enums. Source 1 Source 2
This library uses enums to define options we can pass into directives, for example side in rdxHoverCardContent.
My real gripe with using enums here is not even any of the reasons outlined in the videos, we can even ignore them for now but the main pain point here is that just to pass an option to side I have to first import the enum, declare a variable in the class and then reference that variable in the template just so I can configure the side.
So instead of being able to do
<ng-template
rdxHoverCardContent
[side]="bottom"
[sideOffset]="8"
>I have to do
import { RdxPositionSide } from "@radix-ng/primitives/core";
...
<ng-template
rdxHoverCardContent
[side]="HoverCardSide.Bottom"
[sideOffset]="8"
>
...
export class Component {
protected readonly HoverCardSide = RdxPositionSide;
}If instead, side was typed as "top" | "bottom", I would still get all the type-safety I get from enums but I would also get better dx when using the library.
Other libraries
radix-ui follows the same.