Skip to content

Commit

Permalink
Type fixes following @kof and @HenriBeck reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre committed Jul 16, 2018
1 parent abcf8d8 commit ef4819a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
14 changes: 4 additions & 10 deletions src/createHoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React, {Component, type ComponentType} from 'react'
import PropTypes from 'prop-types'
import defaultTheming from 'theming'
import jss, {getDynamicStyles, SheetsManager} from './jss'
import jss, {getDynamicStyles, SheetsManager, JssSheet} from './jss'
import compose from './compose'
import getDisplayName from './getDisplayName'
import * as ns from './ns'
Expand Down Expand Up @@ -34,11 +34,6 @@ const dynamicStylesNs = Math.random()
*
*/

type DynamicSheet = {
update: ({}) => any,
detach: () => any,
classes: {}
} | void | null;
type DefaultProps = {
classes: {}
};
Expand All @@ -50,7 +45,7 @@ type Props = {
};
type State = {
theme: Theme,
dynamicSheet?: DynamicSheet,
dynamicSheet?: JssSheet,
classes?: ?{}
};

Expand Down Expand Up @@ -98,7 +93,6 @@ export default (stylesOrCreator: StylesOrThemer, InnerComponent: any, options: O
delete defaultProps.classes

class Jss extends Component<Props, State> {
state: State;
unsubscribeId: any => any;
static displayName = `Jss(${displayName})`
static InnerComponent = InnerComponent
Expand All @@ -111,7 +105,7 @@ export default (stylesOrCreator: StylesOrThemer, InnerComponent: any, options: O
}
static defaultProps = defaultProps

constructor(props: Props, context: ComponentType<Props>) {
constructor(props: Props, context: any) {
super(props, context)
const theme = isThemingEnabled ? themeListener.initial(context) : noTheme

Expand Down Expand Up @@ -208,7 +202,7 @@ export default (stylesOrCreator: StylesOrThemer, InnerComponent: any, options: O
return {theme, dynamicSheet, classes}
}

manage({theme, dynamicSheet}: {theme: Theme, dynamicSheet: DynamicSheet}) {
manage({theme, dynamicSheet}: State) {
const contextSheetOptions = this.context[ns.sheetOptions]
if (contextSheetOptions && contextSheetOptions.disableStylesGeneration) {
return
Expand Down
3 changes: 2 additions & 1 deletion src/jss.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export {
SheetsRegistry,
getDynamicStyles,
SheetsManager,
createGenerateClassName as createGenerateClassNameDefault
createGenerateClassName as createGenerateClassNameDefault,
StyleSheet as JssSheet

This comment has been minimized.

Copy link
@HenriBeck

HenriBeck Jul 17, 2018

StyleSheet is not being exported by jss. I don't know how this is even working

This comment has been minimized.

Copy link
@gomesalexandre

gomesalexandre Jul 17, 2018

Author Owner

When I go to the definition of jss from my editor, it leads me to the index.d.ts of jss. Now, JS doesn't have interfaces so not sure how this resolves.

Edit : Actually, VSCode was directing me to the @types folder, not the jss one. I can see that stylesheet is not exported, should we import it from the jss/lib/StyleSheet directly or duplicate it on the repo ?

This comment has been minimized.

Copy link
@HenriBeck

HenriBeck Jul 18, 2018

No, this will break in the next version of Jss. Duplicating it, for now, might be the best option.

This comment has been minimized.

Copy link
@kof

kof Jul 18, 2018

should we fix it in v10? Export all the types?

This comment has been minimized.

Copy link
@HenriBeck

HenriBeck Jul 18, 2018

Yeah, it will also make it easier to type plugins if necessary.

This comment has been minimized.

Copy link
@kof
} from 'jss'

export default create(preset())
11 changes: 4 additions & 7 deletions src/types.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
// @flow
import {JssSheet} from './jss'

export type Options = {
theming?: {
themeListener: any => any
},
inject?: [],
jss?: any,
index?: ?number
...JssSheet.options
};
export type Theme = {};
export type Styles = {[string]: {}};
export type ThemerFn = (theme: Theme) => {};
export type ThemerFn = (theme: Theme) => Styles;
export type StylesOrThemer = Styles | ThemerFn;
export type Classes<S> = {|
[$Keys<S>]: string
Expand Down

0 comments on commit ef4819a

Please sign in to comment.