MaterialDesign-Font-Build icon indicating copy to clipboard operation
MaterialDesign-Font-Build copied to clipboard

Typescript declarations for css class names

Open rebior opened this issue 1 year ago • 0 comments

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.

rebior avatar Nov 10 '24 14:11 rebior