-
Notifications
You must be signed in to change notification settings - Fork 310
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
Typing mismatch for fontWeight property (maybe others?) #124
Comments
This is a bug in our type definition. Your usage is correct. Will fix. |
@nmn can i take this please, |
type fontWeight should also support of type |
@kevintyj There are some In the meantime we have two options:
Considering the increasing use of variable fonts, I think option 2 is good for this. @purohitdheeraj You are welcome to put up this PR, but be prepared for some discussion about the better option mentioned above. |
I agree that option 2 would be a better temporary fix until the new type function is adopted! The only downside being that arbitrary |
@kevintyj You‘re right but I guess this approach in the following code could work. And if I understand this right, this allows strings “400”, “bolder” and numeric values like 400? But I guess it’s a bit more complicated than that. 😄 // /packages/stylex/src/StyleXTypes.js
type TTokens = $ReadOnly<{
[string]:
| number
| string
| $ReadOnly<{ default: number | string, [string]: number | string }>,
}>; |
@timwehrle The nested object case is handled elsewhere. The fix would be as simple as: type fontWeight =
| 'inherit'
| 'normal'
| 'bold'
| 'bolder'
| 'lighter'
| 100
| 200
| 300
| 400
| 500
| 600
| 700
| 800
| 900
| string
| number; @purohitdheeraj The race is on!
Yeah, as explained we cannot accept raw numbers as variable values. It is error prone because you may expect some number to be auto-converted to The const vars = stylex.defineVars({
heavy: stylex.types.number(700),
red500: stylex.types.color('tomato'),
size_lg: stylex.types.length('64px'),
// And I'm thinking about the following patterns:
size_sm: stylex.types.rem(2),
size_md: stylex.types.px(36),
// Further, I want something like this, but it needs to be immutable/unthemeable:
media_mobile: stylex.types.media('(max-width: 480px)'),
}); I'll write a full proposal with details about the types function, but know that it will end up generating I'm also working on a full CSS parser which will be used to validate the values being passed to the type function. |
hello everyone, this question might be silly i made the changes in what should be the next step
even if someone has already solved it |
It should work? I just tested it out and was able to make a commit to that file. Perhaps check your local gitignore config? git config --get core.excludesfile EDIT I also dont think thats the file you should edit, it should be the |
@purohitdheeraj Please edit the After that, running NOTE: |
The problem
fontWeight
has to be a string as perTTokens
, but cannot be a string as perStyleXCSSTypes
.How to reproduce
I want to do:
BUT :
So I got:
Type 'StyleXClassNameFor<"fontWeight", string>' is not assignable to type 'StyleXClassNameFor<"fontWeight", Readonly<"initial" | "inherit" | "unset" | "normal" | "bold" | "bolder" | "lighter" | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | null | undefined>>
The text was updated successfully, but these errors were encountered: