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

Using Flow $Exact type utility with Properties doesn't work #17

Closed
frenic opened this issue Mar 16, 2018 · 1 comment
Closed

Using Flow $Exact type utility with Properties doesn't work #17

frenic opened this issue Mar 16, 2018 · 1 comment
Labels

Comments

@frenic
Copy link
Owner

frenic commented Mar 16, 2018

The $Exact type utility in Flow could be useful to fail when an unknown (possibly misspelled) style property is used. But this fails for some reason when a known vendor property is used.

const css: $Exact<CSS.Properties<*>> = {
  height: '1px',           // <- OK
  MozAppearance: 'button', // <- Error
};

// All branches are incompatible:
//  - Either cannot assign object literal to `css` because property `MozAppearance` is missing in
//   `StandardLonghandProperties` [1] but exists in object literal [2].
//  - Or cannot assign object literal to `css` because property `MozAppearance` is missing in
//   `StandardShorthandProperties` [3] but exists in object literal [2].

This however works:

const css: CSS.Properties<*> & $Shape<CSS.Properties<*>> = {
  height: '1px',           // <- Ok
  MozAppearance: 'button', // <- Ok
  someUnknown: 'abc'       // <- Error
};

All I could find was this bug when $Exact is used along with spread. But it doesn't really cover this problem.

I'm trying to understand what's happening but I'm not that familiar with Flow.

@frenic
Copy link
Owner Author

frenic commented May 17, 2019

Fixed in #67

@frenic frenic closed this as completed May 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant