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

Typescript declarations for css class names #30

Open
rebior opened this issue Nov 10, 2024 · 0 comments
Open

Typescript declarations for css class names #30

rebior opened this issue Nov 10, 2024 · 0 comments

Comments

@rebior
Copy link

rebior commented Nov 10, 2024

Hi,
I like that projects and I'm using the web font in a typescript project to create dynamic content. Therefore I have to set the css class names from my script. I created a script that extracts the icon names into a mdi.d.ts file so I can use it easily in my code with support of the IDE. The generated mdi.d.ts exports a single type that matches the icon names:

export type IconClass =
"mdi-ab-testing" |
"mdi-abacus" |
"mdi-abjad-arabic" |
 ...
"mdi-zodiac-virgo" |
"mdi-blank";

This type can then also be used for strongly typed interfaces. The import must be a "type only" import:

import type { IconClass } from "./mdi.js"

It would be nice if such a declaration for typescript could be added to @mdi/font with the types field in package.config pointing to it.

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