Skip to content

Commit

Permalink
feat: 🎸 improve TypeScript definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Jul 14, 2018
1 parent 696dd4d commit 21a3a49
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 17 deletions.
65 changes: 49 additions & 16 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
type ICssLikeObject = object;
import * as CSS from 'csstype';

interface ICssProps extends CSS.Properties, CSS.PropertiesHyphen {}

interface ICssLikeObject extends ICssProps {
[selector: string]: any | ICssLikeObject;
}

interface IUnits {
px: (num: number) => string;
Expand All @@ -17,6 +23,12 @@ interface IUnits {
vmax: (num: number) => string;
}

type TDynamicCss = (css: ICssLikeObject) => string;
type THyperstyleElement = object;
type THyperstyle = (...args) => THyperstyleElement;
type THyperscriptType = string | Function;
type THyperscriptComponent = Function;

interface NanoRenderer extends Partial<IUnits> {
client: boolean;
raw: string;
Expand All @@ -28,21 +40,42 @@ interface NanoRenderer extends Partial<IUnits> {
* Need to install `rule` addon.
*/
rule?: (css: ICssLikeObject, block?: string) => string;
drule?: (...args) => any;
sheet?: (...args) => any;
dsheet?: (...args) => any;
jsx?: (...args) => any;
style?: (...args) => any;
styled?: (...args) => any;
cache?: (...args) => any;
global?: (...args) => any;
keyframes?: (...args) => any;
hydrate?: (...args) => any;
hyperstyle?: (...args) => any;
pipe?: (...args) => any;
drule?: (css: ICssLikeObject, block?: string) => TDynamicCss;
sheet?: (cssMap: {[s: string]: ICssLikeObject}, block?: string) => {[s: string]: string};
dsheet?: (cssMap: {[s: string]: ICssLikeObject}, block?: string) => {[s: string]: TDynamicCss};
jsx?: (
type: THyperscriptType,
css: ICssLikeObject,
dynamicCss?: TDynamicCss,
block?: string
) => THyperscriptComponent;
style?: (
type: THyperscriptType,
css: ICssLikeObject,
dynamicCss?: TDynamicCss,
block?: string
) => THyperscriptComponent;
styled?: (
type: THyperscriptType
) => (css: ICssLikeObject, dynamicCss?: TDynamicCss, block?: string) => THyperscriptComponent;
cache?: (css: ICssLikeObject) => string;
global?: (css: ICssLikeObject) => void;
keyframes?: (...args) => string;
hydrate?: (sh: CSSStyleSheet) => void;
hyperstyle?: (cssMap: {[s: string]: ICssLikeObject}, block?: string) => THyperstyle;
putRule?: (...args) => any;
createRef?: (...args) => any;
ref?: (...args) => any;
useStyles?: (...args) => any;
withStyles?: (...args) => any;
useStyles?: (
cssMap: {[s: string]: ICssLikeObject},
fn: (props, styles: {[s: string]: string}) => THyperstyleElement,
block?: string
) => THyperscriptComponent;
withStyles?: (
cssMap: {[s: string]: ICssLikeObject},
fn: THyperscriptComponent,
block?: string
) => THyperscriptComponent;
s?: object;
units?: IUnits;
}
Expand All @@ -56,6 +89,6 @@ interface INanoOptions {
stringify?: (obj: object) => string;
}

type TCreateNano = (options: INanoOptions) => NanoRenderer;
type TCreateNano = (options?: INanoOptions) => NanoRenderer;

export const create: TCreateNano;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"rtl-css-js": "^1.9.0",
"css-tree": "^1.0.0-alpha.28",
"stacktrace-js": "^2.0.0",
"sourcemap-codec": "^1.4.1"
"sourcemap-codec": "^1.4.1",
"csstype": "^2.5.5"
},
"devDependencies": {
"@types/react": "16.3.17",
Expand Down

0 comments on commit 21a3a49

Please sign in to comment.