picostyle icon indicating copy to clipboard operation
picostyle copied to clipboard

How to use picostyle by TypeScript?

Open anharu2394 opened this issue 7 years ago • 1 comments

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'.

anharu2394 avatar Oct 07 '18 13:10 anharu2394

@anharu2394 Can try with

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

const d = picostyle(h as createNode);

tngan avatar Nov 22 '18 08:11 tngan