frenic / csstype

Strict TypeScript and Flow types for style based on MDN data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FontWeight doesn't accept absolute values passed as strings

villasv opened this issue · comments

I'm getting Type '"100"' is not assignable to type 'FontWeight | undefined'. when using a library that specifies a few CSS constants and declares it's types as possibly stringified numerals.

Union string (... | string) is needed to make this work today and is avoided whenever possible. To solve this we first need to implement a TS4.1 alternative and use number | `${number}` to make 100 and "100" work, but not e.g. "lihgter".

Any pointer for me to go about it? I think I have the time to contribute, but I couldn't figure out how to based on recent pull requests.

That would be helpful! This guy converts CSSType-"types" into understandable TypeScript types. The string template literal needs to be opt-in here somewhere so we can generate a d.ts with string template literals and one without later on.

Union string is now also applied wherever union number is applied. Released in 3.0.10. I need more time to solve this separately with template string for TS4.1+.