Skip to content

Commit

Permalink
fix(typescript): fix types, add "test" file
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey committed Mar 25, 2021
1 parent 7dc9f23 commit e240017
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 7 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist
*.d.ts
*.test-d.ts
6 changes: 4 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type StyleObject = CSSProperties | CSSPsuedos | {
}
export type HypostyleProperties = CSSPropertyNames | CSSPsuedos | string;
export type HypostyleObject = CSSProperties | CSSPsuedos | {
[property in HypostyleProperties]: HypostyleObject | string | number | boolean | undefined;
[property in HypostyleProperties]: HypostyleObject | string | number | string[] | number[] | boolean | undefined;
}

export interface Tokens {
Expand Down Expand Up @@ -56,7 +56,7 @@ export type Theme = {

export type Options = {}

export declare function hypostyle(theme?: Theme, options?: Options): {
export type Hypostyle = {
css(
props: ((tokens: Theme['tokens']) => Partial<HypostyleObject>) |
Partial<HypostyleObject>
Expand All @@ -70,3 +70,5 @@ export declare function hypostyle(theme?: Theme, options?: Options): {
styles: HypostyleObject;
};
}

export function hypostyle(theme?: Theme, options?: Options): Hypostyle
26 changes: 26 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { hypostyle } from '.'
import presets from './presets'

declare module '.' {
interface UserTheme {
tokens: {
color: {
primary: 'blue'
}
}
}
}

const o = hypostyle({
...presets,
tokens: {
color: {
primary: 'blue'
}
}
})

o.css(tokens => ({
c: tokens.color.primary,
mx: [2, 4]
}))
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "hypostyle",
"version": "0.1.0",
"description": "",
"description": "Minimalist 5th Generation CSS-in-JS built for concision and extension. Fast af, powered by nano-css.",
"main": "index.js",
"types": "index.d.js",
"types": "index.d.ts",
"files": [
"index.js",
"utils",
"presets"
"index.d.ts",
"presets.js",
"presets.d.ts"
],
"scripts": {
"test": "node -r esm test",
Expand Down
6 changes: 6 additions & 0 deletions presets.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as lib from '.'

export const tokens: lib.Tokens;
export const breakpoints: lib.Unitless[];
export const shorthands: lib.Shorthands;
export const macros: lib.Macros;
7 changes: 6 additions & 1 deletion presets/index.js → presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,9 @@ const macros = {
taj: { ta: 'justify' }
}

module.exports = { tokens, breakpoints, shorthands, macros }
module.exports = {
tokens,
breakpoints,
shorthands,
macros
}

0 comments on commit e240017

Please sign in to comment.