snabbdom / snabbdom-to-html

Render Snabbdom Vnode’s to HTML strings
91 stars 21 forks source link

Type definition errors #35

Open gfmio opened 7 years ago

gfmio commented 7 years ago

Hi! I'm just trying to get snabbdom-to-html working with TypeScript and I'm getting a bunch of error messages about the type definitions using tsc v2.4.2:

node_modules/snabbdom-to-html/type-definitions/snabbdom-to-html.d.ts(1,9): error TS2305: Module '"/Users/gfmio/projects/js/csam-new/csam/node_modules/snabbdom/snabbdom"' has no exported member 'VNode'.
node_modules/snabbdom-to-html/type-definitions/snabbdom-to-html.d.ts(9,3): error TS2666: Exports and export assignments are not permitted in module augmentations.
node_modules/snabbdom-to-html/type-definitions/snabbdom-to-html.d.ts(12,16): error TS2665: Invalid module name in augmentation. Module 'snabbdom-to-html/init' resolves to an untyped module at '/Users/gfmio/projects/js/csam-new/csam/node_modules/snabbdom-to-html/init.js', which cannot be augmented.
node_modules/snabbdom-to-html/type-definitions/snabbdom-to-html.d.ts(24,16): error TS2665: Invalid module name in augmentation. Module 'snabbdom-to-html/modules' resolves to an untyped module at '/Users/gfmio/projects/js/csam-new/csam/node_modules/snabbdom-to-html/modules/index.js', which cannot be augmented.
node_modules/snabbdom-to-html/type-definitions/snabbdom-to-html.d.ts(29,16): error TS2665: Invalid module name in augmentation. Module 'snabbdom-to-html/modules/index' resolves to an untyped module at '/Users/gfmio/projects/js/csam-new/csam/node_modules/snabbdom-to-html/modules/index.js', which cannot be augmented.
node_modules/snabbdom-to-html/type-definitions/snabbdom-to-html.d.ts(34,16): error TS2665: Invalid module name in augmentation. Module 'snabbdom-to-html/modules/attributes' resolves to an untyped module at '/Users/gfmio/projects/js/csam-new/csam/node_modules/snabbdom-to-html/modules/attributes.js', which cannot be augmented.
node_modules/snabbdom-to-html/type-definitions/snabbdom-to-html.d.ts(39,16): error TS2665: Invalid module name in augmentation. Module 'snabbdom-to-html/modules/class' resolves to an untyped module at '/Users/gfmio/projects/js/csam-new/csam/node_modules/snabbdom-to-html/modules/class.js', which cannot be augmented.
node_modules/snabbdom-to-html/type-definitions/snabbdom-to-html.d.ts(44,16): error TS2665: Invalid module name in augmentation. Module 'snabbdom-to-html/modules/props' resolves to an untyped module at '/Users/gfmio/projects/js/csam-new/csam/node_modules/snabbdom-to-html/modules/props.js', which cannot be augmented.
node_modules/snabbdom-to-html/type-definitions/snabbdom-to-html.d.ts(49,16): error TS2665: Invalid module name in augmentation. Module 'snabbdom-to-html/modules/style' resolves to an untyped module at '/Users/gfmio/projects/js/csam-new/csam/node_modules/snabbdom-to-html/modules/style.js', which cannot be augmented.

The first error can be fixed by replacing the line with import {VNode} from "snabbdom/vnode";.

The second error can be fixed by replacing the declare module "snabbdom-to-html" block with

declare module "snabbdom-to-html" {
  export function toHTML(vnode: VNode): string;
}

My linter also alerted me that the declaration of Module can be changed to export type Module = (vnode: VNode, attributes: Map<string, number | string>) => void;.

I couldn't figure out how to get rid off the other error messages (except for by deleting them) unless you move them to separate files.

Can I submit these initial fixes as a pull request? Alternatively, can I quickly rewrite the library in TypeScript? That should also solve all problems.

Cheers!

acstll commented 6 years ago

Can I submit these initial fixes as a pull request? Alternatively, can I quickly rewrite the library in TypeScript? That should also solve all problems.

sorry @gfmio somehow I missed your issue completely.

Yes, feel free to submit a PR.

Also a TypeScript rewrite has been on our radar for a long time (you can check old issues). Go ahead if you have the time.

acstll commented 6 years ago

Also, in a complete rewrite scenario, it would be great to consider suggestions and opinions from both the snabbdom and the Cycle.js communities (the @cycle/html module depends on this library). Both projects are written in TS.