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() does not enforce NestedCSSProperties type on record keys #276

Open
alexmoore0 opened this issue Jul 18, 2018 · 2 comments
Open

Comments

@alexmoore0
Copy link

The stylesheet() function does not enforce NestedCSSProperties as keys on the child objects within the argument. This vastly reduces the usability of the stylesheet() function, as compared to the strict types enforced by style().

This code compiles just fine:

const styles = stylesheet({
  item: {
    borderLeft: "4px solid transparent",
    "this is a not a CSS property": "transparent",
  }
});

However, if I remove the borderLeft property, the TS compiler recognizes the invalid key.

TypeScript: 2.8.4
Typestyle: 2.0.1
Node: 8.2.1

@anion155
Copy link
Contributor

anion155 commented Oct 3, 2018

#290

@s-KaiNet
Copy link

s-KaiNet commented Jun 3, 2020

It looks like the issue appears again - the workaround is to explicitly cast the object to a proper type, i.e.

const styles = stylesheet({
  item: {
    borderLeft: "4px solid transparent",
    "this is a not a CSS property": "transparent",
  }
} as Record<string, types.NestedCSSProperties>);

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

3 participants