Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back the type IxIcon #61

Open
freed00m opened this issue Jul 23, 2024 · 0 comments
Open

Bring back the type IxIcon #61

freed00m opened this issue Jul 23, 2024 · 0 comments

Comments

@freed00m
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant