ix-icons icon indicating copy to clipboard operation
ix-icons copied to clipboard

Bring back the type IxIcon

Open freed00m opened this issue 7 months ago • 0 comments

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.

freed00m avatar Jul 23 '24 15:07 freed00m