cssinjs / jss

JSS is an authoring tool for CSS which uses JavaScript as a host language.
https://cssinjs.org
MIT License
7.08k stars 399 forks source link

Unable to re-use Styles type in a typescript project with declarations set to true. #1450

Closed ymor closed 3 years ago

ymor commented 3 years ago

Expected behavior: I should be able to re-use the exported Styles type, when my typescript project has declarations set to true.

Describe the bug: On using the Styles export in a typescript project that has declarations set to true, I receive the following error: Exported variable 'createUseThemeStyles' has or is using name 'Func' from external module "/sandbox/node_modules/jss/src/index" but cannot be named.

Reproduction: https://codesandbox.io/s/sad-jackson-q3bnq I like to create a custom ThemeProvider so I can provide a default for tests. I also like to create a custom createUseStyles that injects this theme so it's all in one place. However on setting the type of the styles param to Styles I receive the error described above.

Versions (please complete the following information):

kof commented 3 years ago

Anybody knows what this is about @cssinjs/typescript ?

ymor commented 3 years ago

Hi @kof, Sorry I totally forgot about this issue and its has since been resolved. I can define something like the following which does what I expect.:

export const createUseMyThemeStyles =
    <C extends string, Props = unknown>(styles: Styles<C, Props, MyTheme> | ((theme: MyTheme) => Styles<C, Props, undefined>)) => 
    createUseStyles(styles, {theming: theming})