Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stylesheet.create does not support strict TypeScript type checking or intellisense #392

Open
rpggio opened this issue May 16, 2020 · 3 comments

Comments

@rpggio
Copy link

rpggio commented May 16, 2020

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"
  }
});
@zhenwenc
Copy link

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.

@zgotsch
Copy link
Contributor

zgotsch commented May 28, 2020

I think I did something related to this at Flexport. @dmnd can you check flow-typed-overrides for aphrodite?

@zanona
Copy link

zanona commented Jun 6, 2020

I had the same issue with emotion, and I believe it has to do with the pseudo or attribute selectors.
emotion-js/emotion#1888
Ideally we would need to have those declared under a nest property so it can be correctly typed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants