ix-icons
ix-icons copied to clipboard
Bring back the type IxIcon
I'm submitting a...
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
Current behavior
During development, we use IxIcon type to check if we used correct icon.
/**
* The original IxIcon type union includes (string & {})
* very hard to exclude, the Exclude typescript function would result in never type.
*
* This Literal IxIcon font will help in checking for renamed / removed icons as the storybook
* would simply fail to build.
*/
type GetLiteral<Type extends string | number, Value> = Value extends Type
? Type extends Value
? never
: Value
: never
type ObtainLiterals<T> = T extends infer R ? GetLiteral<string, R> : never
type IxIconsLiterals = ObtainLiterals<IxIcons>
Expected behavior
To be able to import IxIcons in TypeScript
Minimal reproduction of the problem with instructions
import { IxIcons } from '@siemens/ix-icons/dist/types/components'
What is the motivation / use case for changing the behavior?
In case I derive Icon literal type, I have nice way in code that checks if I actually used the correct name of an icon.
It can easily happen during migrations, that you might remove or rename icon, and our code would just compile and have incorect icon name.