Created
October 9, 2025 12:52
-
-
Save zecka/3dd1a165c6abd385ad5954a2d7349afe to your computer and use it in GitHub Desktop.
Css var to css path union type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type CssPath<T extends string> = | |
| T extends `--${infer Rest}` // enlève les "--" du début | |
| ? ReplaceDashWithSlash<Rest> // remplace les tirets restants | |
| : never | |
| type ReplaceDashWithSlash<S extends string> = | |
| S extends `${infer Head}-${infer Tail}` | |
| ? `${Head}/${ReplaceDashWithSlash<Tail>}` | |
| : S | |
| // Exemple : | |
| type Demo = "--icon-name-demo" | "--icon-name-demo2" | |
| type DemoPath = CssPath<Demo> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment