Skip to content

Commit

Permalink
fix: improve attribute types
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey committed Dec 25, 2021
1 parent 6145eb2 commit f794276
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 72 deletions.
68 changes: 0 additions & 68 deletions index.js

This file was deleted.

12 changes: 8 additions & 4 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ import { Properties as CSSProperties } from 'csstype'

type CSSPropertyNames = keyof CSSProperties

type Tag = Function | { children: HyposcriptNode[] } | keyof HTMLElementTagNameMap | string
export type HyposcriptNode = string
export type Element = Function | { children: Child[] } | keyof HTMLElementTagNameMap | string
export type Props = {
style?: { [property in CSSPropertyNames]: string | number }
[attribute: string]: any
}
export type Child = string
export type PropsWithChildren<T> = T & {
children?: HyposcriptNode
children?: Child | Child[]
}

const aliases = {
Expand Down Expand Up @@ -41,7 +45,7 @@ export function styleObjectToString(style: { [property in CSSPropertyNames]: str
return s
}

export function h(tag: Tag, props: Record<string, any>, ...children: HyposcriptNode[] | HyposcriptNode[][]) {
export function h(tag: Element, props: Props, ...children: Child[] | Child[][]) {
// multiple children as immediate children
if (typeof tag === 'object' && tag.children) return tag.children.join('')

Expand Down

0 comments on commit f794276

Please sign in to comment.