diff --git a/packages/jss/src/index.d.ts b/packages/jss/src/index.d.ts index 819aa5a9c..d08a0f47f 100644 --- a/packages/jss/src/index.d.ts +++ b/packages/jss/src/index.d.ts @@ -16,7 +16,9 @@ type Func = T extends undefined ? ((data: P) => R) : ((data: P & {theme type NormalCssProperties = CSSProperties type NormalCssValues = K extends keyof NormalCssProperties ? NormalCssProperties[K] : JssValue -export type JssStyle = +export type JssStyle = { + fallbacks?: JssStyle | (JssStyle[]) +} & ( | { [K in keyof NormalCssProperties]: | NormalCssValues @@ -30,7 +32,7 @@ export type JssStyle = | JssStyle | Func | undefined> | MinimalObservable - } + }) export type Styles< Name extends string | number | symbol = string, diff --git a/packages/jss/tests/jss-tests.ts b/packages/jss/tests/jss-tests.ts index 4ad75e8d5..1c44c6818 100644 --- a/packages/jss/tests/jss-tests.ts +++ b/packages/jss/tests/jss-tests.ts @@ -72,6 +72,35 @@ attachedStyleSheet.addRules({ } }) +// fallbacks test +attachedStyleSheet.addRules({ + rule4: { + fallbacks: { + fontFamily: 'other', + color: '#black' + }, + fontFamily: 'Roboto', + color: '#FFFFFF' + }, + // @ts-expect-error + rule5: { + fallbacks: { + borderRadius: ['solid', 2], + fontSize: Symbol() + }, + borderRadius: ['solid', 2], + fontSize: 17 + }, + // @ts-expect-error + rule6: { + fallbacks: Symbol() + }, + container: { + display: 'flex', + fallbacks: [{display: 'box'}, {display: 'flex-box'}] + } +}) + const styleSheet2 = sharedInstance.createStyleSheet({ container: { background: '#000099'