-
Notifications
You must be signed in to change notification settings - Fork 256
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
Strict mode and review CSS Types #206
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit d8033f6:
|
If I understand it correctly this new TypeScript feature may allow for typing the shorthands: microsoft/TypeScript#40336 |
@drewbourne i thought so too, but after speaking briefly with @benoitgrelard it doesn't seem like it. But we could be wrong. If that feature works for us, that would be amazing! |
At first glance I didn't think so, but yeah I could be totally wrong. On a second look, it does seem that TS would be able to infer parts of a string (the Split example they give is quite telling for example: I need to take a deeper read… |
@benoitgrelard I think it's now in |
@dirtyrolf daaamn that is slick! Thanks for looking into it! |
Taking over from #116
This PR adds a strict mode feature, originally proposed by @fgnass
Strict mode is
false
by default.I also did a review of the CSS Types, which closes #48. For example, this allows numbers in
margin
properties, since internally we convert them topx
.Important note
When
strict: true
shorthands have a stricter syntax:AFAIK its not possible to type strings that can contain multiple values.
Unless, somehow, we create all the possible combinations of all tokens? (sounds like a terrible, terrible idea)
Say you have 4 space tokens: $1, $2, $3, $4
And you wanna add margin on all sides, you can do:
margin: "$2" // this passes validation, because its a single value in a string and its a token
Now you wanna set margin top/bottom and margin left/right
margin: "$2 $4" // As far as TS is concerned, this is still a single string so it cant offer you autocomplete
The only way would be to construct all the possible strings: