diff --git a/types/jss/index.d.ts b/types/jss/index.d.ts index 3318f9a565..b19b82ab0e 100644 --- a/types/jss/index.d.ts +++ b/types/jss/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Brenton Simpson // Oleg Slobodskoi // Thomas Crockett +// Sebastian Silbermann // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -137,6 +138,10 @@ export declare class JSS { * Creates a new instance of JSS. */ export function create(options?: Partial): JSS; +/** + * Creates a GenerateClassName function + */ +export function createGenerateClassName(): GenerateClassName; declare const sharedInstance: JSS; /** * A global JSS instance. diff --git a/types/jss/jss-tests.ts b/types/jss/jss-tests.ts index 5e9a876036..8822264282 100644 --- a/types/jss/jss-tests.ts +++ b/types/jss/jss-tests.ts @@ -2,11 +2,12 @@ import { create as createJSS, + createGenerateClassName, SheetsRegistry, default as sharedInstance, } from 'jss'; -const jss = createJSS().setup({}); +const jss = createJSS().setup({ createGenerateClassName }); jss.use({}, {}); // $ExpectType JSS const styleSheet = jss.createStyleSheet( @@ -46,6 +47,9 @@ const rule = attachedStyleSheet.addRule('dynamicRule', { color: 'indigo' }); rule.prop('border-radius', 5).prop('color'); // $ExpectType string attachedStyleSheet.classes.dynamicRule; // $ExpectType string +const generateClassName = createGenerateClassName(); +const dynamicRuleClassName = generateClassName(rule, attachedStyleSheet); + attachedStyleSheet.deleteRule('dynamicRule'); // test that `addRule` supports the shorthand signature