developit / vhtml

Render JSX/Hyperscript to HTML strings, without VDOM 🌈

Home Page:http://npm.im/vhtml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Thoughts on TypeScript support?

AndrewLeedham opened this issue · comments

First of all, great project. The simplicity is beautiful.

I am curious on your thoughts on adding typings in some form to this repo from a maintainer perspective. I am happy to do the work here, but don't want to create a maintenance burden.

In order of personal preference:

  1. Rewrite/convert the package with TypeScript, using your microbundle package?
  2. Add .d.ts files to the current implementation?
  3. Create a definitely typed package for @types/vhtml?

For my project, I cheated by pulling in Preact's type definitions.

I have a modules.d.ts in my project directory that looks like this:

declare module "vhtml" {
  function h(name: string, attrs?: Record<string, any>): string;

  // Let's borrow JSX types from Preact
  import { JSX } from "preact";
  namespace JSX {
    export import IntrinsicElements = JSX.IntrinsicElements;
    export type Element = string;
  }
}

Obviously very hacky, needs much improvement, and not recommended for professional setups.

I wrote some type definitions and made a PR to DefinitelyTyped. If you need the typings right now, you might want to look at my repository instead. see #25 (comment)

@types/vhtml is now public. I think we can close this issue.