Skip to content

Conversation

@jviide
Copy link
Collaborator

@jviide jviide commented Sep 18, 2019

This pull request adds basic TypeScript type declarations for htm.

The typings are rather minimal. Only htm's default export is typed, and it's just an object with one method: bind(h). Here h is the pragma function and its argument types are quite lax for convenience's sake. bind's result is a function whose return type is based on h's return type:

// const html: (strings: TemplateStringsArray, ...values: any[]) => number | number[]
const html = htm.bind((type, props, ...children) => {
   return children.length;
});

The type declarations are located in src/index.d.ts. That file is then copied to dist/index.d.ts and mini/index.d.ts as a part of the build process, after Microbundle has done its magic.

The src/index.d.ts file is copied to dist/index.d.ts and
mini/index.d.ts as a part of the build process.
@jviide jviide requested a review from developit September 18, 2019 19:29
@jviide jviide merged commit b590948 into developit:master Oct 3, 2019
@jviide jviide deleted the typings branch October 3, 2019 10:12
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 this pull request may close these issues.

2 participants