dfilatov / vidom

Library to build UI based on virtual DOM
MIT License
415 stars 16 forks source link

Any plans on TypeScript support and d.ts generation? #243

Closed stgolem closed 7 years ago

stgolem commented 7 years ago

TypeScript is so much cooler than plain JavaScript! And we have typings for everything! But not for vidom :disappointed:

Have you got plans for it?

dfilatov commented 7 years ago

Personally, I'm not a fan of TypeScript, but I agree that typescript definitions could be helpful for people which use it. If you're familiar with TypeScript, could you add definitions and make pull request? It shouldn't be difficult.

stgolem commented 7 years ago

I'm not that good at TypeScript also. Never created definitions for complex modules. Also i am not that good at vidom (just started to learn and try it). So maybe someone else out there in community?

dfilatov commented 7 years ago

If you have any questions about Vidom, feel free to ask )

stgolem commented 7 years ago

The best way to create typings is to know the structure of classes and objects. If you have something like that, maybe internally, it would help a lot. From documentation i cannot see much, mostly there are just generic definitions. What we need is full structure with inheritance and types used in params.

dfilatov commented 7 years ago

Let's discuss, for instance for children() method of TagNode (https://github.com/dfilatov/vidom/wiki/TagNode-API#children)

TagNode children(
    VNode child | Array<VNode> children | String text
)

Could you write what is not clear here and what you would expect to see to help you?

stgolem commented 7 years ago

Ok. Here you go. What is TagNode? A class? Is there any nested classes? What is TagNode properties (get, set) and functions? How do i create TagNode? Same for VNode.

See? You have high level API documented, with examples and all. But we need class structure. In other case i have to go to sources and spend time composing that.

dfilatov commented 7 years ago

Ok, let's start with top-level definitions and creating.

VNode = TagNode | TextNode | FragmentNode | ComponentNode | FunctionComponentNode

Is there any nested classes?

No

How do i create TagNode?

All types of nodes are created via top-level factory function node(...).

dfilatov commented 7 years ago

Methods of TagNode:

All these methods are setters and setup corresponding fields. There's no any getters. They all return the same instance (this) for chainability.

dfilatov commented 7 years ago

Methods of TextNode:

dfilatov commented 7 years ago

Methods of FragmentNode:

dfilatov commented 7 years ago

Methods of ComponentNode and FunctionComponentNode:

dfilatov commented 7 years ago

@stgolem Is it enough to go ahead?

stgolem commented 7 years ago

That is great start! I think from here and docs i can compose some typings already. If i have further questions i'll ask here.

dfilatov commented 7 years ago

I'm gonna add vidom.d.ts in 0.9

dfilatov commented 7 years ago

closed in favour of #306