Swizz/snabbdom-pragma

Typescript strict mode supported?

jvanbruegge opened this issue · 16 comments

I haven't tried it, but I don't think this works with typescript's --strict flag, because of missing JSX namespace declarations

Swizz commented

I dont really know typescript. I found the '--jsxFactory' to add the createElement pragma.

Snabbdom-pragma, is transpiler independant, and transform createElement call to Snabbdom vnode.

Swizz commented

Yes, typescript expects a global JSX namespace declaration.

Swizz commented

Snabbdom provides a declaration for VNode, but it seems we need something like this: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/df09b2a3368b7f47959f86247a12ab95b9d261f4/types/react/index.d.ts#L2721

But instead of React.ReactElement with VNode

Swizz commented

import { VNode } from 'snabbdom';
yes

Swizz commented

Live on : feature/definitely-typed

This is a pretty naive implementation but seem to fill all the needs.
Give it a try, and feel free to contribute.

Swizz commented

@jvanbruegge Did you take an eye on it ? This is what you need ?

I think it is, but can you publish it as alpha release, then I can test properly

Swizz commented

Couldn't you npm install it from branch ?

Swizz/Snabbdom-pragam#feature/definitely-typed

Yeah, that worked.
You don't get errors with this, sadly you have to put a /// <reference> in your code to make it work, but only in the index file, so that's not too bad

Swizz commented

I will dive into Typescript someday soon, I promise.

As this change is not really a breaking one, I can release it at your go.

yeah, go for it
we can improve the typings in the future

Swizz commented

Npm published : v2.2.0