diff --git a/types/jss/css.d.ts b/types/jss/css.d.ts
deleted file mode 100644
index 06a9c620cf..0000000000
--- a/types/jss/css.d.ts
+++ /dev/null
@@ -1,130 +0,0 @@
-// These CSS typings adapted from TypeStyle: https://github.com/typestyle/typestyle
-
-import { Observable } from './observable'
-import * as csstype from 'csstype'
-
-export type ObservableProperties
= {
- [K in keyof P]: P[K] | Observable
-}
-
-export type CSSProperties =
- & ObservableProperties
- & ObservableProperties;
-
-export interface JssProps {
- '@global'?: CSSProperties;
- extend?: string;
- composes?: string | string[];
-}
-
-export interface JssExpand {
- animation:
- | {
- delay: CSSProperties['animationDelay'];
- direction: CSSProperties['animationDirection'];
- duration: CSSProperties['animationDuration'];
- iterationCount: CSSProperties['animationIterationCount'];
- name: CSSProperties['animationName'];
- playState: CSSProperties['animationPlayState'];
- timingFunction: any;
- }
- | CSSProperties['animation'];
- background:
- | {
- attachment: CSSProperties['backgroundAttachment'];
- color: CSSProperties['backgroundColor'];
- image: CSSProperties['backgroundImage'];
- position: CSSProperties['backgroundPosition'] | number[]; // Can be written using array e.g. `[0 0]`
- repeat: CSSProperties['backgroundRepeat'];
- size: Array; // Can be written using array e.g. `['center' 'center']`
- }
- | CSSProperties['background'];
- border:
- | {
- color: CSSProperties['borderColor'];
- style: CSSProperties['borderStyle'];
- width: CSSProperties['borderWidth'];
- }
- | CSSProperties['border'];
- boxShadow:
- | {
- x: any;
- y: any;
- blur: any;
- spread: any;
- color: CSSProperties['color'];
- inset?: 'inset'; // If you want to add inset you need to write "inset: 'inset'"
- }
- | CSSProperties['boxShadow'];
- flex:
- | {
- basis: CSSProperties['flexBasis'];
- direction: CSSProperties['flexDirection'];
- flow: CSSProperties['flexFlow'];
- grow: CSSProperties['flexGrow'];
- shrink: CSSProperties['flexShrink'];
- wrap: CSSProperties['flexWrap'];
- }
- | CSSProperties['flex'];
- font:
- | {
- family: CSSProperties['fontFamily'];
- size: CSSProperties['fontSize'];
- stretch: CSSProperties['fontStretch'];
- style: CSSProperties['fontStyle'];
- variant: CSSProperties['fontVariant'];
- weight: CSSProperties['fontWeight'];
- }
- | CSSProperties['font'];
- listStyle:
- | {
- image: CSSProperties['listStyleImage'];
- position: CSSProperties['listStylePosition'];
- type: CSSProperties['listStyleType'];
- }
- | CSSProperties['listStyle'];
- margin:
- | {
- bottom: CSSProperties['marginBottom'];
- left: CSSProperties['marginLeft'];
- right: CSSProperties['marginRight'];
- top: CSSProperties['marginTop'];
- }
- | CSSProperties['margin'];
- padding:
- | {
- bottom: CSSProperties['paddingBottom'];
- left: CSSProperties['paddingLeft'];
- right: CSSProperties['paddingRight'];
- top: CSSProperties['paddingTop'];
- }
- | CSSProperties['padding'];
- outline:
- | {
- color: CSSProperties['outlineColor'];
- style: 'none' | 'hidden' | 'dotted' | 'dashed' | 'solid' | 'double' | 'groove' | 'ridge' | 'inset' | 'outset';
- width: any;
- }
- | CSSProperties['outline'];
- textShadow:
- | {
- x: any;
- y: any;
- blur: any;
- color: CSSProperties['color'];
- }
- | CSSProperties['textShadow'];
- transition:
- | {
- delay: CSSProperties['transitionDelay'];
- duration: CSSProperties['transitionDuration'];
- property: CSSProperties['transitionProperty'];
- timingFunction: CSSProperties['transitionTimingFunction'];
- }
- | CSSProperties['transition'];
-}
-
-export type JssExpandArr = { [k in keyof JssExpand]?: JssExpand[k] | Array };
-
-export type SimpleStyle = CSSProperties & JssProps & JssExpandArr;
-export type Style = SimpleStyle | Observable;
diff --git a/types/jss/index.d.ts b/types/jss/index.d.ts
index 767c777bb3..d0136216ed 100644
--- a/types/jss/index.d.ts
+++ b/types/jss/index.d.ts
@@ -1,15 +1,9 @@
-// Type definitions for jss 9.5
+// Type definitions for jss 9.3
// Project: https://github.com/cssinjs/jss#readme
// Definitions by: Brenton Simpson
// Oleg Slobodskoi
-// Thomas Crockett
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-// TypeScript Version: 2.3
-
-import { Style } from './css';
-
-export type Styles = Record;
-export type Classes = Record;
+// TypeScript Version: 2.2
export interface Rule {
className: string;
@@ -19,12 +13,13 @@ export interface Rule {
prop(key: string, value: any): this;
toJSON(): string;
}
-
-export interface StyleSheet {
+export interface StyleSheet {
// Gives auto-completion on the rules declared in `createStyleSheet` without
// causing errors for rules added dynamically after creation.
- classes: Classes;
- options: RuleOptions;
+ classes: {
+ [K in keyof T]: string;
+ } & { [key: string]: string };
+ options: any;
linked: boolean;
attached: boolean;
/**
@@ -40,21 +35,21 @@ export interface StyleSheet {
* Will insert a rule also after the stylesheet has been rendered first time.
*/
addRule(style: Style, options?: Partial): Rule;
- addRule(name: Name, style: Style, options?: Partial): Rule;
+ addRule(name: string, style: Style, options?: Partial): Rule;
/**
* Create and add rules.
* Will render also after Style Sheet was rendered the first time.
*/
- addRules(styles: Partial>, options?: Partial): Rule[];
+ addRules(styles: { [key: string]: Style }, options?: Partial): Rule[];
/**
* Get a rule by name.
*/
- getRule(name: Name): Rule;
+ getRule(name: string): Rule;
/**
* Delete a rule by name.
* Returns `true`: if rule has been deleted from the DOM.
*/
- deleteRule(name: Name): boolean;
+ deleteRule(name: string): boolean;
/**
* Get index of a rule.
*/
@@ -63,37 +58,39 @@ export interface StyleSheet {
* Update the function values with a new data.
*/
update(data?: {}): this;
- update(name: Name, data: {}): this;
+ update(name: string, data: {}): this;
/**
* Convert rules to a CSS string.
*/
toString(options?: { indent?: number }): string;
}
-export type GenerateClassName = (rule: Rule, sheet?: StyleSheet) => string;
-
+export type GenerateClassName = (rule: Rule, sheet?: StyleSheet) => string;
+export interface Style {
+ [key: string]: any;
+}
export interface JSSPlugin {
[key: string]: () => Partial<{
- onCreateRule(name: string, style: Style, options: RuleOptions): Rule;
- onProcessRule(rule: Rule, sheet: StyleSheet): void;
- onProcessStyle(style: Style, rule: Rule, sheet: StyleSheet): Style;
- onProcessSheet(sheet: StyleSheet): void;
- onChangeValue(value: any, prop: string, rule: Rule): any;
- onUpdate(data: {}, rule: Rule, sheet: StyleSheet): void;
+ onCreateRule(name: string, style: Style, options: RuleOptions): Rule,
+ onProcessRule(rule: Rule, sheet: StyleSheet): void,
+ onProcessStyle(style: Style, rule: Rule, sheet: StyleSheet): Style,
+ onProcessSheet(sheet: StyleSheet): void,
+ onChangeValue(value: any, prop: string, rule: Rule): any,
+ onUpdate(data: {}, rule: Rule, sheet: StyleSheet): void,
}>;
}
export interface JSSOptions {
- createGenerateClassName(): GenerateClassName;
+ createGenerateClassName(): GenerateClassName;
plugins: ReadonlyArray;
virtual: boolean;
insertionPoint: string | HTMLElement;
}
-export interface RuleFactoryOptions {
+export interface RuleFactoryOptions {
selector: string;
- classes: Classes;
- sheet: StyleSheet;
+ classes: { [key: string]: string };
+ sheet: StyleSheet;
index: number;
jss: JSS;
- generateClassName: GenerateClassName;
+ generateClassName: GenerateClassName;
}
export interface RuleOptions {
index: number;
@@ -101,23 +98,23 @@ export interface RuleOptions {
}
declare class JSS {
constructor(options?: Partial);
- createStyleSheet(
- styles: Partial>,
+ createStyleSheet(
+ styles: T,
options?: Partial<{
- media: string;
- meta: string;
- link: boolean;
- element: HTMLStyleElement;
- index: number;
- generateClassName: GenerateClassName;
- classNamePrefix: string;
+ media: string,
+ meta: string,
+ link: boolean,
+ element: HTMLStyleElement,
+ index: number,
+ generateClassName: GenerateClassName,
+ classNamePrefix: string,
}>,
- ): StyleSheet;
- removeStyleSheet(sheet: StyleSheet): this;
+ ): StyleSheet;
+ removeStyleSheet(sheet: StyleSheet): this;
setup(options?: Partial): this;
use(plugin: JSSPlugin): this;
- createRule(style: Style, options?: RuleFactoryOptions): Rule;
- createRule(name: Name, style: Style, options?: RuleFactoryOptions): Rule;
+ createRule(style: Style, options?: Partial): Rule;
+ createRule(name: string, style: Style, options?: Partial): Rule;
}
/**
* Creates a new instance of JSS.
diff --git a/types/jss/jss-tests.ts b/types/jss/jss-tests.ts
index 8e53780988..0cf3f51350 100644
--- a/types/jss/jss-tests.ts
+++ b/types/jss/jss-tests.ts
@@ -7,25 +7,13 @@ import {
const jss = createJSS().setup({});
-const styleSheet = jss.createStyleSheet(
+const styleSheet = jss.createStyleSheet(
{
ruleWithMockObservable: {
- subscribe: observer => {
- const next = typeof observer === 'function' ? observer : observer.next;
- next({ background: 'blue', display: 'flex' });
- next({ invalidKey: 'blueish' }); // $ExpectError
-
- // only kebab case allowed in observables
- next({ 'align-items': 'center' });
- next({ alignItems: 'center' }); // $ExpectError
- return {
- unsubscribe() {}
- };
- }
+ subscribe() {}
},
container: {
display: 'flex',
- 'align-items': 'center',
width: 100,
opacity: .5,
},
@@ -65,21 +53,10 @@ styleSheet.addRules({
},
});
-styleSheet.addRule('badProperty', {
- thisIsNotAValidProperty: 'blah', // $ExpectError
-});
-
-styleSheet.addRule('badValue', { // $ExpectError
- 'align-items': 'thisIsNotAValidValue',
-});
-
styleSheet.detach();
-const styleSheet2 = sharedInstance.createStyleSheet({
+sharedInstance.createStyleSheet({
container: {
background: '#000099',
}
});
-
-styleSheet2.classes.container; // $ExpectType string
-styleSheet2.classes.notAValidKey; // $ExpectError
diff --git a/types/jss/observable.d.ts b/types/jss/observable.d.ts
deleted file mode 100644
index ff6a5f0219..0000000000
--- a/types/jss/observable.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copied from https://github.com/cssinjs/jss/blob/6ed7963786d5ef899075e95f81efc9530342154f/src/types.js
-
-export type Observable = {
- subscribe(observerOrNext: ObserverOrNext): Subscription
-}
-
-export type Observer = {
- next: NextChannel
-}
-
-export type NextChannel = (value: T) => void
-export type ObserverOrNext = Observer | NextChannel
-
-export type Unsubscribe = () => void
-export type Subscription = {
- unsubscribe: Unsubscribe
-}
diff --git a/types/jss/package.json b/types/jss/package.json
deleted file mode 100644
index 201f7e2d14..0000000000
--- a/types/jss/package.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "private": true,
- "dependencies": {
- "csstype": "^1.6.0"
- }
-}