aphrodite
aphrodite copied to clipboard
Stylesheet.create does not support strict TypeScript type checking or intellisense
CSSProperties
type does not support strict typing. It allows any property name to be used for a style. This prevents type checking and intellisense for Stylesheet.create
.
It appears this is due to CSSPropertiesLossy
in the type.
Example: https://codesandbox.io/s/aphrodite-no-type-checking-itwip?file=/src/index.ts
const styles1 = StyleSheet.create({
blue: {
backgroundColor: "lightblue",
// no strict typing
murgin: "5px"
}
});
I find this is very annoying as well, in addition the browser simply ignores any invalid property, so that manual errors are not detected.
However, I think its intended to be like this, since not all CSS properties are declared in CSSProperties
type (eg userSelect
), and in order to support custom selector handlers.
I think I did something related to this at Flexport. @dmnd can you check flow-typed-overrides for aphrodite?
I had the same issue with emotion, and I believe it has to do with the pseudo or attribute selectors.
https://github.com/emotion-js/emotion/issues/1888
Ideally we would need to have those declared under a nest
property so it can be correctly typed.