Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upfeat: tightened typing for Object Interpolation (CSSProperties) #644
Conversation
for tightened typing
aacd96a
to
1721864
|
Hi @shqld! |
|
Hi @Anber !Thanks for your reply. We can specify any types we want by overriding types using TypeScript's Declaration Merging (as I described above), so I believe it will still have some effect to do something like in this PR without special support for custom properties. At least no disadvantage is considered, IMHO. |
Motivation
Object Interpolation is very useful especially for creating sass-like mixins such as
However, currently
CSSPropertiestype accepts any keys and values even outside of CSS rule stuff. This is problematic for type safety and usability (e.g. auto-completion).Summary
In this PR, I've just replaced declaration of
CSSProperties.Concretely, replaced
[key: string]: string | numberwithcsstype.Propertieswhich is responsible for covering all available key-value pairs of css property.This allows us more relialbe type cheking and usable auto-completion for Object Interpolation without downside in runtime.
For extendability of property types, internal interface called
Propertiesis exported so that users can merge interface at their discretion in the user-land.Test plan