-
-
Notifications
You must be signed in to change notification settings - Fork 400
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
Support typings for jss-plugin-nested #1036
Comments
I just fixed the issue in #973 Should be released with the next alpha, though this will only allow you to write this but not correctly type-check this. |
@HenriBeck Can I test new type now? |
Because the types are now inside |
export type Style = {[key: string]: Style | any}
export type Styles<Name extends string = string> = Record<Name, Style> @HenriBeck it seems that now everything goes any. |
// index.d.ts
import { CSSProperties } from "jss/css";
export type Style = { [key: string]: Style } | CSSProperties
export type Styles<Name extends string = string> = Record<Name, Style> Is there any problem in this code? jss.createStyleSheet({
a: {
fontWeight: "bold",
"&:hover": {
"hi": {
backgroundColor: "red"
}
}
},
}); |
The first problem is that this type-definitions doesn't support function values, observables (though they are not that often used), expandable values, array values. And |
@HenriBeck I think the current type definition is little helpful. It passes type checkings for any style with any possible plugin, but at the same time, it can't autocomplete any property at all.
I don't know about function values, observables well. But array value, maybe it's something like const styles = {
container: {
transition: [['opacity', '200ms'], ['width', '300ms']]
}
} Is this what you mean? Then I think it can be solved by just introducing JssValue. export type JssValue =
| string
| number
| Array<string | number | Array<string | number> | '!important'>
| null
| false;
export type Style = { [key: string]: Style | JssValue } | CSSProperties It's just a draft. I didn't check it worked, But I'm willing to make it better.
I totally agree with you. But, how about making jss.createStyleSheet<NestedStyle>({
// ...
}) Of course, we can offer default And as far as I know, import { ObservableProperties } from "jss/css";
export type CSSProperties =
& ObservableProperties<csstype.Properties<Length>>
& ObservableProperties<csstype.PropertiesHyphen<Length>>; Why isn't there typing for plugin-nested? It seems just a simple inconsistency. |
Is your feature request related to a problem? Please describe.
this code can't pass type check.
Describe the solution you'd like
#795
I'd thought the first item in this issue(Add typings to the extend plugin and preset default)
is about the typings for plugin-nested, but I checked the v10.0.0-alpha.10 and it seems not.
Is there any reason that the typings for nested rule is not included in the next release?
Are you willing to implement it?
Yes
The text was updated successfully, but these errors were encountered: