-
Notifications
You must be signed in to change notification settings - Fork 44
Description
Problem
Since the enum FlagSource is only exported as Type from types.d.ts and not as value it can't be used in the code e.g. like this.
import { FlagSource } from 'flagsmith'
if (source === FlagSource.None) {
...
}Directly comparing with the string "NONE" should be avoided (see https://typescript-eslint.io/rules/no-unsafe-enum-comparison/).
So the only workaround is using it like this:
import type { FlagSource } from 'flagsmith/types'
if (source === ('NONE' as FlagSource.NONE)) {
...
}Which is not ideal.
Possible Solutions
- Export the enum as value e.g. from the flagsmith core file
- Get rid of the enum and use string literal types (https://www.typescriptcourse.com/string-literal-unions-over-enums)
FloEdelmann and bdchauvette
Metadata
Metadata
Assignees
Labels
No labels