Skip to content

Commit

Permalink
Merge branch 'upgrade-ts-4.4.2' into refine-style-types
Browse files Browse the repository at this point in the history
  • Loading branch information
kof committed Sep 12, 2021
2 parents 81ec5b9 + d2a2b4b commit 87387ae
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions packages/react-jss/tests/types/withStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ ComponentTest = () => <ResultingComponent property="" />

/* -------------------- Failing Cases -------------------- */

// A function argument cannot provide another defined theme type conflicting with `undefined`
function failingFunctionRedefineTheme(theme: MyTheme): Styles<string, unknown, any> {
function failingFunctionWrongTheme(theme: MyTheme): Styles<string, unknown, MyTheme> {
return {
someClassName: '',
anotherClassName: {
Expand All @@ -146,7 +145,7 @@ function failingFunctionRedefineTheme(theme: MyTheme): Styles<string, unknown, a
}
}

function passingFunctionUnknownTheme(theme: MyTheme): Styles<string, unknown, unknown> {
function failingFunctionNullTheme(theme: MyTheme): Styles<string, unknown, null> {
return {
someClassName: '',
anotherClassName: {
Expand All @@ -155,17 +154,7 @@ function passingFunctionUnknownTheme(theme: MyTheme): Styles<string, unknown, un
}
}

function passingFunctionNullTheme(theme: MyTheme): Styles<string, unknown, null> {
return {
someClassName: '',
anotherClassName: {
fontWeight: 'bold'
}
}
}
// TODO clarify all these tests, because they started to work/fail differently
// after migration to typescript 4 and probably rely on a fragile a ts api
withStyles(failingFunctionRedefineTheme)(SimpleComponent)
withStyles(passingFunctionUnknownTheme)(SimpleComponent)
// @ts-expect-error
withStyles(passingFunctionNullTheme)(SimpleComponent)
// @ts-expect-error - can't use a wrong theme
withStyles(failingFunctionWrongTheme)(SimpleComponent)
// @ts-expect-error - can't use null as a theme
withStyles(failingFunctionNullTheme)(SimpleComponent)

0 comments on commit 87387ae

Please sign in to comment.