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

Question: Why does some properties allow strings while other doesn't? #84

Closed
henninghall opened this issue Mar 2, 2020 · 5 comments
Closed

Comments

@henninghall
Copy link

Hi @frenic, I have a question! 😀

Most properties seem to allow string values even if they have a finite number of valid values, for instance:

type AlignItemsProperty = Globals | SelfPosition | "baseline" | "normal" | "stretch" | string;
type FlexFlowProperty = Globals | "column" | "column-reverse" | "nowrap" | "row" | "row-reverse" | "wrap" | "wrap-reverse" | string;

But other doesn't:

type FlexDirectionProperty = Globals | "column" | "column-reverse" | "row" | "row-reverse";
type FlexWrapProperty = Globals | "nowrap" | "wrap" | "wrap-reverse";

I ran into these kinds of problems while using the properties that don't allow any string.

Is this intentional? 🤔

@meyer
Copy link

meyer commented Mar 2, 2020

if you search closed issues for string you’ll see this question gets asked fairly frequently (it’s probably worth a README FAQ). There’s an explanation here: #8 (comment)

@henninghall
Copy link
Author

Thanks! So this is actually solved by #74? Is that also already released or does it come in v3?

@frenic
Copy link
Owner

frenic commented Mar 6, 2020

The autocomplete issue is solved in 3.0.0@beta.1 by that PR. Not the type checking part.

@henninghall
Copy link
Author

Alright! Do you already have an issue for the type checking part or do you want to keep this open for that?

@frenic
Copy link
Owner

frenic commented Mar 8, 2020

We should close this. I don't believe there's much more we can do to improve type checking at this moment. We also have to keep in mind that false positive type errors are more annoying than false positive warnings in e.g. a linting tool. CSSType should only provide basic type checking and let the responsible to the developer and other tools where values becomes more complicated.

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