@@ -16,7 +16,7 @@ const expectedCustomTheme: MyTheme = {color: 'red'}
1616
1717/* -------------------- THEME ARGUMENT -------------------- */
1818// Regular, static styles work fine
19- const themeArg1 = createUseStyles ( theme => ( {
19+ const themeArg1 = createUseStyles ( ( theme ) => ( {
2020 someClassName : '' ,
2121 anotherClassName : {
2222 fontWeight : 'bold'
@@ -26,20 +26,20 @@ const themeArg1ClassesPass = themeArg1()
2626
2727// Theme type assumed to be the default
2828// Nested theme declaration banned
29- // @ts -expect-error
30- const themeArg2 = createUseStyles ( theme => ( {
31- themeNotAllowed : ( { theme : innerTheme } ) => ( {
32- fontWeight : 'bold'
29+ const themeArg2 = createUseStyles ( ( parentTheme ) => ( {
30+ themeNotAllowed : ( { theme} : { theme : MyTheme } ) => ( {
31+ color : theme . color
3332 } )
3433} ) )
3534// @ts -expect-error
3635const themeArg2ClassesFail = themeArg2 ( { theme : { } } )
3736// @ts -expect-error
3837const themeArg2ClassesFail2 = themeArg2 ( { theme : expectedCustomTheme } )
39- const themeArg2ClassesPass = themeArg2 ( { theme : expectedDefaultTheme } )
38+ // @ts -expect-error
39+ const themeArg2ClassesFail2 = themeArg2 ( { theme : expectedDefaultTheme } )
4040
4141// Props declaration is allowed
42- const themeArg3 = createUseStyles < string , MyProps > ( theme => ( {
42+ const themeArg3 = createUseStyles < string , MyProps > ( ( theme ) => ( {
4343 onlyPropsAllowed : ( { ...props } ) => ( {
4444 fontWeight : 'bold'
4545 } )
@@ -52,16 +52,15 @@ const themeArg3ClassesPass = themeArg3(expectedCustomProps)
5252const themeArg3ClassesPass2 = themeArg3 ( { ...expectedCustomProps , theme : expectedDefaultTheme } )
5353
5454// Nested props declaration banned
55- const themeArg4 = createUseStyles < string , MyProps > ( theme => ( {
55+ const themeArg4 = createUseStyles < string , MyProps > ( ( theme ) => ( {
5656 onlyPropsAllowed : ( { ...props } ) => ( {
5757 fontWeight : 'bold' ,
58- // @ts -expect-error
5958 propsNotAllowed : ( { ...innerProps } ) => ''
6059 } )
6160} ) )
6261
6362// Supplied theme type is acknowledged
64- const themeArg5 = createUseStyles < string , unknown , MyTheme > ( theme => ( { } ) )
63+ const themeArg5 = createUseStyles < string , unknown , MyTheme > ( ( theme ) => ( { } ) )
6564// @ts -expect-error
6665const themeArg5ClassesFail = themeArg5 ( { theme : { } } )
6766// @ts -expect-error
@@ -81,7 +80,7 @@ const themeArg6ClassesFail2 = themeArg6({theme: expectedDefaultTheme})
8180const themeArg6ClassesPass = themeArg6 ( { theme : expectedCustomTheme } )
8281
8382// Props can be determined implicitly
84- const themeArg7 = createUseStyles ( theme => ( {
83+ const themeArg7 = createUseStyles ( ( theme ) => ( {
8584 checkbox : ( { property} : MyProps ) => ( {
8685 borderColor : property
8786 } )
@@ -172,53 +171,14 @@ const noThemeArg4ClassesPass2 = noThemeArg4({...expectedCustomProps, theme: expe
172171const noThemeArg5 = createUseStyles < string , MyProps , MyTheme > ( {
173172 singleNest : {
174173 fontWeight : 'bold' ,
175- singleValue : ( { property , theme } ) => '' ,
176- nestOne : ( { property, theme} ) => ( {
174+ // @ts -expect-error
175+ nestOne : ( { property, theme} : MyProps & { theme : MyTheme } ) => ( {
177176 color : 'red' ,
178- // @ts -expect-error
179- nothingAllowed : ( { theme : innerTheme , ...innerProps } ) => ''
177+ display : ( ) => 'block'
180178 } )
181179 }
182180} )
183181
184- // Nested declarations are banned (double nest test)
185- const noThemeArg6 = createUseStyles < string , MyProps , MyTheme > ( {
186- doubleNest : {
187- fontWeight : 'bold' ,
188- singleValue : ( { property, theme} ) => '' ,
189- firstNest : {
190- color : 'red' ,
191- innerSingleValue : ( { property, theme} ) => '' ,
192- secondNest : ( { property, theme} ) => ( {
193- backgroundColor : 'blue' ,
194- // @ts -expect-error
195- nothingAllowed : ( { theme : innerTheme , ...innerProps } ) => ''
196- } )
197- }
198- }
199- } )
200-
201- // Nested declarations are banned (triple nest test)
202- const noThemeArg7 = createUseStyles < string , MyProps , MyTheme > ( {
203- tripleNest : {
204- fontWeight : 'bold' ,
205- singleValue : ( { property, theme} ) => '' ,
206- firstNest : {
207- color : 'red' ,
208- innerSingleValue : ( { property, theme} ) => '' ,
209- secondNest : {
210- backgroundColor : 'blue' ,
211- innerMostSingleValue : ( { property, theme} ) => '' ,
212- thirdNest : ( { property, theme} ) => ( {
213- display : 'block' ,
214- // @ts -expect-error
215- nothingAllowed : ( { theme : innerMostTheme , ...innerMostProps } ) => ''
216- } )
217- }
218- }
219- }
220- } )
221-
222182// Props can be determined implicitly
223183const noThemeArg8 = createUseStyles ( {
224184 checkbox : ( { property} : MyProps ) => ( {
0 commit comments