Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/jss/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ type Func<P, T, R> = T extends undefined ? ((data: P) => R) : ((data: P & {theme
type NormalCssProperties = CSSProperties<string | number>
type NormalCssValues<K> = K extends keyof NormalCssProperties ? NormalCssProperties[K] : JssValue

export type JssStyle<Props = any, Theme = undefined> =
export type JssStyle<Props = any, Theme = undefined> = {
fallbacks?: JssStyle<Props, Theme> | (JssStyle<Props, Theme>[])
} & (
| {
[K in keyof NormalCssProperties]:
| NormalCssValues<K>
Expand All @@ -30,7 +32,7 @@ export type JssStyle<Props = any, Theme = undefined> =
| JssStyle<Props, Theme>
| Func<Props, Theme, JssValue | JssStyle<undefined, undefined> | undefined>
| MinimalObservable<JssValue | JssStyle | undefined>
}
})

export type Styles<
Name extends string | number | symbol = string,
Expand Down
29 changes: 29 additions & 0 deletions packages/jss/tests/jss-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down