matype / picostyle

Ultra small CSS in JS library in 0.4 KB
Other
359 stars 34 forks source link

How to use picostyle by TypeScript? #50

Open anharu2394 opened 5 years ago

anharu2394 commented 5 years ago

I would like to use picostyle by TypeScript.

An error occurred in this code.

import { h } from "hyperapp"
import picostyle from "picostyle"

const styled = picostyle(h)
      TS2345: Argument of type '<Attributes>(nodeName: string | Component<Attributes, any, any>, attributes?: Attributes | undefined, ...children: (string | number | VNode<{}> | Children[] | null)[]) => VNode<Attributes>' is not assignable to parameter of type 'createNode'.
  Types of parameters 'nodeName' and 'nodeName' are incompatible.
    Type 'string | Component<Attributes>' is not assignable to type 'string | Component<Attributes | null, any, any>'.
      Type 'Component<Attributes>' is not assignable to type 'string | Component<Attributes | null, any, any>'.
        Type 'Component<Attributes>' is not assignable to type 'Component<Attributes | null, any, any>'.
          Types of parameters 'attributes' and 'attributes' are incompatible.
            Type 'Attributes | null' is not assignable to type 'Attributes'.
              Type 'null' is not assignable to type 'Attributes'.
tngan commented 5 years ago

@anharu2394 Can try with

import { h } from 'hyperapp';
import picostyle, { createNode } from 'picostyle';

const d = picostyle(h as createNode);