Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thoughts on TypeScript support? #25

Closed
AndrewLeedham opened this issue Jun 16, 2020 · 4 comments · May be fixed by #26 or #27
Closed

Thoughts on TypeScript support? #25

AndrewLeedham opened this issue Jun 16, 2020 · 4 comments · May be fixed by #26 or #27

Comments

@AndrewLeedham
Copy link

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?
This was referenced Jun 16, 2020
@pastelmind
Copy link

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.

@pastelmind
Copy link

pastelmind commented Dec 16, 2020

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)

@pastelmind
Copy link

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

@AndrewLeedham
Copy link
Author

Nice work @pastelmind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants