Skip to content

Add Typing (DTS file) - #311

Merged
jorgebucaran merged 1 commit into
hyperapp:masterfrom
Swizz:fresh-typing
Sep 18, 2017
Merged

jorgebucaran merged 1 commit into
hyperapp:masterfrom
Swizz:fresh-typing

Conversation

@Swizz

@Swizz Swizz commented Jul 21, 2017 •

Copy link
Copy Markdown
Contributor

This follows and closes #279

The first attemps of a DTS file was made with a lot of stuffs in minds.
I chosen to Revoke completely my last attempt, to propose a more sanitized one.
The main goal of this PR is now to move with iteration. To easily discuss about declarations.

First, I propose you to talk about the basics, and the VNode, h() stuffs.

This declaration file, is 98% based on the Picodom one by @pspeter3 because the Vdom system is (almost) the same.

Here I have only overloaded h() and added JSX support. jorgebucaran/superfine#17 (comment)

I have also added the Emit interface and app function as starting point.

Bonus : Emit use @andrewiggins awesome `keyof Events` :
keyof Events

Steps

  • Step 1 - Virtual DOM + JSX + Emit
  • Step 2 - View + Actions
  • Step 3 - Events
  • Step 4 - Application + Mixin

@codecov

codecov Bot commented Jul 21, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #311 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #311   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           2      2           
  Lines         148    148           
  Branches       46     46           
=====================================
  Hits          148    148

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dd51e18...4862023. Read the comment docs.

Comment thread hyperapp.d.ts
data?: Data,
...children: VElement<{}>[]
): VNode<Data>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Swizz Why is this repeated?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Swizz Is there any way to declare that using the same definition? If it's impossible, then can we leave it out? The fact that children can be arguments is an implementation detail needed by JSX, but users should definitely not use h like that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am looking for a way to express children could be an array ov VElements or the rest of args could be too.

In Snabbdom-pragma, I am using the following

type Children = VNode<{}>[] | VNode<{}> | string | number
type CircularChildren = Children | Children[]

export function h<Data>(
   tag: Component<Data> | string,
   data?: Data,
   ...children: CircularChildren 
 ): VNode<Data>

CircularChildren was about a quick fix regarding :

const arr = [
  [<div>Hello1.1</div>, <div>Hello1.2</div>],
  [<div>Hello2.1</div>, <div>Hello2.2</div>]
]
const vnode = <div> { arr } </div>

@jorgebucaran jorgebucaran Jul 22, 2017 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Swizz Can we just leave out the ...children? h() supports ...children just because of JSX. If JSX didn't exist, h() would be always Array<VirtualNode>.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing.
Can I use h() with a number as children ?

plus: do you prefer the Array<Data> notation instead of the Data[] one ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know we could use both, but let's go on with Array<Data>.

Can I use h() with a number as children ?

Yes, you can.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only in h() or we can tell a VirtualElement could be either a VirtualNode, a string, or a number.

The last one will affect :

  • h() children parameter
  • Component children
  • VirtualNode children

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum.. Array<Data> could be a little bit confusing.

h(
  children: Array<VirtualElement<{}>>
)
h(
  children: VirtualElement<{}>[]
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Swizz Why don't you just repeat VirtualNode | string everywhere?

@Swizz Swizz Jul 22, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you prefer ?

I think is more correct to tell once a VirtualNode is ... and then the user will be mind this.
And IntelliSens will yield about the right type when aliased. It still asking for number, string, or VirtualNode. So this is just more DRY.

good type asking in VS Code

@jorgebucaran

jorgebucaran commented Jul 22, 2017 •

Copy link
Copy Markdown
Collaborator

Great work @Swizz! Can we work on renaming a few things?

I was thinking instead of VNode, better VirtualNode.

And add types for State, Actions, Mixins, etc.

Note that actions allow nested actions so in flow:

{
  [action: string]:
    | Actions
    | (State, Actions, any) => ActionResult
}

Does that make sense?


We'll also need an ActionResult type:

A partial state or Promise that resolves to a partial state.

Maybe also a definition for CustomEvent:

event(State, Actions, any): any

Comment thread hyperapp.d.ts Outdated

// VNode part

export interface VNode<Data> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Swizz Why does VNode<Data> mean?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to @pspeter3 DTS for Picodom, I am pretty sure this is to allow to define the Props interface of a vnode. And to help for JSX 🎉

Props in VNode

(VS Code is awesome regarding TypeScript)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so this is only useful if the user defines an interface for the VirtualNode data? Hmm. Nice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes using :

const link = h('a', {})

Will do not raise anything. Thats why we are using VNode<{}> as default. Instead of any.

Comment thread hyperapp.d.ts Outdated
children: VElement<{}>[]
}

export type VElement<Data> = VNode<Data> | string

@jorgebucaran jorgebucaran Jul 22, 2017 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Swizz Is this possible:

export interface VNode<Data> {
  tag: string
  data?: Data
  children: VNode<{}>[]
} | string

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want a VNode to be either a VNode or a string. I never heard it was possible. Union is only possible on type.

I guess, it is right to use a type.
A VirtualNode is a VirtualNode and a VirtualElement could be either a VirtualNode or a string.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just trying to remove the VirtualElement type, which is just confusing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not if you are thinking like the last sentence.

You cant tell a VirtualNode could be a VirtualNode or a string, isnt it ?
But its easy to reason about a VirtualNode and a VirtualElement that could be either a VirtualNode or a string.

The VirtualNode is the vdom thing. And the VirtualElement is in most case a children. And a children could really be another VirtualNode or a string.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, if it's always the children, why not call it VirtualNodeChild?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Swizz ☝️

@Swizz Swizz Jul 22, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it is used as child, but I dont think it is good to limit it at this role by naming.
I do really think VirtualElement is good. @pspeter3, did an awesome job there.

@Swizz

Swizz commented Jul 22, 2017 •

Copy link
Copy Markdown
Contributor Author

@jbucaran

Great work @Swizz!

All credits goes to @pspeter3, seriously

Can we work on renaming a few things? I was thinking instead of VNode, better VirtualNode.

Naming is open to discussion. I am just a bit curious, why is this a concern here and not in Picodom ?

And add types for State, Actions, Mixins, etc.

Dont worry about it. As the DTS will grow faster, I want to move side by side. Now I want to discuss about VNode, JSX, and the app basis. Once done, I will move forward.
Because there are a lot of thing to discuss. So I think is better to be scope minimal.

@jorgebucaran

jorgebucaran commented Jul 22, 2017 •

Copy link
Copy Markdown
Collaborator

Sounds good.

  • VNnode → VirtualNode
  • JSX 👍

Why is this a concern here and not in picodom?

I didn't say picodom anywhere.

EDIT: I do plan to change it in picodom as well.

@Swizz

Swizz commented Jul 22, 2017 •

Copy link
Copy Markdown
Contributor Author

@jbucaran A giant plus DTS will be help to yield and suggest about types for VS Code user and atom-typescript user.
Even if they are using JavaScript instead of TypeScript.

So I plan to add JSDoc too.

JSDoc comments

Comment thread hyperapp.d.ts Outdated
export function h<Data>(
tag: Component<Data> | string,
data?: Data,
children?: VirtualElement<{}>[] | VirtualElement<{}> | number

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Swizz Can you make this just:

VirtualElement<{}>[]?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People using h should use its best form (string, data, array of virtualnode).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without it TSC will yield an exception if I want to use h() that way

h('div', null, h('span', null, 'Hi.'))

This simple thing will not be possible to

h('div', null, 'Hi.')

// ask for
h('div', null, ['Hi.'])

Do you really want to remove features by typing ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Swizz You should not use it that way IMO.

@lukejacksonn What do you think?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a compromise, one option is to add a JSDoc @deprecated comment to steer people away from this function, saying it only exists for JSX support and to use the array version for better perf.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewiggins Is the function info in vscode intellisense picked up from JSDoc comments?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, it is. Screenshot below shows an example of what a user would see for the argument spread version of h:

image

This screenshot shows an example of what a user would see for the array version of h:

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont know how this is a problem in fact. Performance ?

You are saying h('div', null, 'Hi.') is less performant than h('div', null, ['Hi.']) ?
And what if I still want to use this feature like way, I will get typing/editor error/warning even if the function allow the use of it ?
I think this is very effortless to types it. And let users to choose you prefered way to do as both exist.

Let's write a performance warning into the doc and refer it in the JSdoc.

/** Description...
 * @see {@link http://github.com/hyperapp/hyperapp/... | Performance issue}
 */
h(....

@Swizz

Swizz commented Jul 24, 2017

Copy link
Copy Markdown
Contributor Author

Discussed changes pushed, plus JSDoc !

Let's go to the Step 2 !

Comment thread hyperapp.d.ts

/** @namespace [Virtual DOM] */

/** The Virtual DOM representation of an Element

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In all the examples I've seen (and on the JSDoc website itself) it appears the first line of a multi-line doc comment goes on the line after /**. It appears JavaDoc (which I assume JSDoc is inspired from) follows the same styling convention.

Not a big deal, but just thought I'd point it out.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is my first time with JSDoc to be honest. I have let VSCode guide me with

Comment thread hyperapp.d.ts
export interface VirtualNode<Data> {
tag: string
data: Data
children: VirtualNodeChild<{} | null>[]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning for adding | null here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In strict mode null need to be ensured, this is prerequisite if you are using : h('tag', null) node

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a comment about that

Comment thread hyperapp.d.ts
(data?: Data, ...children: VirtualNodeChild<{} | null>[]): VirtualNode<Data>
}

/** The soft way to create a Virtual Node

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "soft" mean? I would just state that h creates VirtualNodes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking for a way to indicate "you can create VirtualNode without h too, but using h is the prefered way".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Virtual Node Factory?

Comment thread hyperapp.d.ts Outdated
*/
export type VirtualNodeChild<Data> = VirtualNode<Data> | string

/** A Component is a function that return a custom Virtual Node

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd put this comment inside the interface, on top of the method definition, and add param documentation. It provides better intellisense in VSCode

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I did it for Emit.

Comment thread hyperapp.d.ts Outdated
* @memberOf [Virtual DOM]
*/
export interface Component<Data> {
(data?: Data, ...children: VirtualNodeChild<{} | null>[]): VirtualNode<Data>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the children args are spread out like this. I believe you just get a direct Array.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already fixed I missed to push this

Comment thread hyperapp.d.ts Outdated

/** @namespace [Application] */

export interface Emit<Data, Events> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we swap the order of these generic parameters to match the order of the function parameters?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to make a Generic parameter optional ? Because we need to give generic a type even if data is optional 😕

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup! You can specify a default type, which makes that generic param optional. For example:

interface SomeInterface<T, U=any>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome thank you !

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general rule, prefer {} to any. Using any allows the consumer to call any property/method for U vs {} will allow the consumer to call none.

@andrewiggins

Copy link
Copy Markdown

To maintain the quality of these typings over time I recommend we add some typings tests to the tests/ folder similar to what I did for picodom. It also makes it clearer to understand how to use the typings appropriately

@Swizz

Swizz commented Jul 25, 2017

Copy link
Copy Markdown
Contributor Author

Thank you for your review @andrewiggins. Your help is a giant plus 👍

To be honest this is 50% laziness. But are you okay to write tests ?
It will ensure typing is understandable and intuitive. And this will help me a lot.

@andrewiggins

Copy link
Copy Markdown

Absolutely! I'll copy what I started in picodom and expand it to include hyperapp features

Comment thread hyperapp.d.ts
children?:
| VirtualNodeChild<{} | null>[]
| VirtualNodeChild<{} | null>
| number

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are numbers converted to strings?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, a h children can be a number, and number will be converted to a string in the VirtualNode representation.

@Mytrill Mytrill Sep 17, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

h also supports array of numbers (all converted to strings) should it then be:

children?: Array<number | VirtualNodeChild<{} | null>> | VirtualNodeChild<{} | null> | number

@pspeter3

Copy link
Copy Markdown
Contributor

After we merge this, doing one for the router would be great.

@Swizz

Swizz commented Jul 28, 2017

Copy link
Copy Markdown
Contributor Author

DTS typing of Hyperapp is a Masterpiece. I think typing the Router will be a lot more easy.

I am a little bit busy these days. I hope I'll push the step 2, within a week.

@Swizz

Swizz commented Jul 28, 2017

Copy link
Copy Markdown
Contributor Author

@pspeter3 Is there a way to ensure all api function to implements ... ?

export interface API<State, Actions, DataIn, DataOut> {
    (state: State, actions: Actions, data: DataIn): DataOut
}

@pspeter3

Copy link
Copy Markdown
Contributor

@Swizz what API functions are you talking about?

@jorgebucaran

Copy link
Copy Markdown
Collaborator

@jorgebucaran jorgebucaran mentioned this pull request Aug 15, 2017
7 tasks done
@mindplay-dk

Copy link
Copy Markdown

How can I install and try this?

@jorgebucaran

Copy link
Copy Markdown
Collaborator

Pong @Swizz @pspeter3.

@Swizz

Swizz commented Aug 18, 2017

Copy link
Copy Markdown
Contributor Author

Quickest way :

In Hyperapp repo

git checkout -b Swizz-fresh-typing master
git pull git://github.com/Swizz/hyperapp.git fresh-typing
npm link

Or clone my repository

git clone -b fresh-typing git://github.com/Swizz/hyperapp.git hyperapp
cd hyperapp
npm link

In you demo project, instead of installing hyperapp release use your local one

npm link hyperapp

@mindplay-dk

Copy link
Copy Markdown

Thanks @Swizz but I'd rather not use links, as these wouldn't work for anyone else cloning the project. (would they?)

According to npm docs, this should work:

"dependencies": {
  "hyperapp": "git://github.com/Swizz/hyperapp.git#fresh-typing",

It even displays the expected hash 93326df on the console during installation - yet, I don't know what it's installing or why, but there are no typings in the installation folder afterwards.

@Swizz

Swizz commented Aug 18, 2017

Copy link
Copy Markdown
Contributor Author

To be honest, I always using in current dev DTS that way.
I know about /// <reference path="..." /> but I never found how to use it.
Maybe @andrewiggins or @pspeter3 could help.

@pspeter3

Copy link
Copy Markdown
Contributor

They would not work. Using the reference path is an outdated way to tell the compiler about type definitions. You can now using the typings key in tsconfig.

@jorgebucaran

Copy link
Copy Markdown
Collaborator

@Swizz Can you please update this with the new API? :)

@Swizz

Swizz commented Aug 19, 2017

Copy link
Copy Markdown
Contributor Author

Now synced with 0.12.0 🎉

@jorgebucaran

jorgebucaran commented Aug 25, 2017 •

Copy link
Copy Markdown
Collaborator

@Swizz What else do we need to merge this?

Comment thread hyperapp.d.ts

export function app<State, Actions, Events>(app: {}): Emit<{} | null, Events>

/** @namespace [JSX] */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there JSX typing in here? I didn't think we implement any of that within Hyperapp.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for the TypeScript compiler. It uses that to type check JSX when generating the equivalent JavaScript

Comment thread hyperapp.d.ts Outdated
export type ActionsResult<State> =
| Partial<State>
| Promise<Partial<State>>
| Function // /!\ TODO: Type the thunk Function

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mission Control: I believe we need a Thunk type.

Comment thread hyperapp.d.ts Outdated
}

export interface View<State, Actions> {
(state: State, actions: Actions): VirtualNode<{}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to add a comment describing this.

jorgebucaran pushed a commit that referenced this pull request Sep 1, 2017
jorgebucaran pushed a commit that referenced this pull request Sep 1, 2017
jorgebucaran pushed a commit that referenced this pull request Sep 3, 2017
jorgebucaran pushed a commit that referenced this pull request Sep 3, 2017
- Remove api.md and display type information next to topic.
- Improve docs.
- See also #311.

@Swizz Swizz left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, Emit copy pasta 😆

@Swizz

Swizz commented Sep 7, 2017 •

Copy link
Copy Markdown
Contributor Author

You can now, please, review the View and Actions part

Comment thread hyperapp.d.ts
state?: State
actions?: Actions
events?: Events
view?: View<State, Actions>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Swizz what about root and mixins?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only minimal, for testing state, actions, events and view. Application typing will come later

Comment thread hyperapp.d.ts Outdated
export interface Events<
State extends Hyperapp.State,
Actions extends Hyperapp.Actions<State>
> {}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Swizz What about an event third data argument?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not arguments but the generics. Here is no interface for Events yet

Comment thread hyperapp.d.ts Outdated
| void


export type ActionsCallers<

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Swizz What if we call these VirtualActions?

/cc @andyrj @pspeter3

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For naming I'll let you choose

@pspeter3

pspeter3 commented Sep 7, 2017

Copy link
Copy Markdown
Contributor

What can I help with here?

Comment thread hyperapp.d.ts
*
* @memberOf [Virtual DOM]
*/
(data: Data, children: VirtualNodeChild<{} | null>[]): VirtualNode<Data>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React and Vue.js refer to data as props, should we follow the same convention?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a good idea! We'd need to change it in app and h too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be complete, Angular refers to it as inputs, although in Angular's case, it's impossible for an input not to also become state inside the component after it's received.

I'm also for renaming, especially since in Vue.js data refers to state inside the component.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Give the names you want to. I am really bad at naming stuff. I followed the API.md

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Swizz Looks good, but what about the tests? We can't merge without tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewiggins Are you always among us? Ready to help me about tests?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm here :) Checkout what I did in jorgebucaran/superfine#19 if you want a simple example of some tests. In summary, add some typescript files that demonstrates how you would expect the types to be used, and add a call to tsc in the test npm script to make sure they compile correctly.

@jorgebucaran

Copy link
Copy Markdown
Collaborator

@Swizz Is this ready? I'm ready to take over now. 😄

@Swizz

Swizz commented Sep 18, 2017

Copy link
Copy Markdown
Contributor Author

There is a lot of commits...
Did I fail my rebase ?

@Swizz
Swizz force-pushed the fresh-typing branch 3 times, most recently from 8010168 to 2db944f Compare September 18, 2017 12:51
@jorgebucaran
jorgebucaran merged commit d6322fc into hyperapp:master Sep 18, 2017
@jorgebucaran jorgebucaran added the enhancement New feature or request label Sep 18, 2017
@pspeter3

Copy link
Copy Markdown
Contributor

🎆

@jorgebucaran

Copy link
Copy Markdown
Collaborator

Merged, merged, merged! 💥 🎉

@Swizz
Swizz deleted the fresh-typing branch December 26, 2017 15:06
jorgebucaran added a commit that referenced this pull request Jan 7, 2018
- Remove api.md and display type information next to topic.
- Improve docs.
- See also #311.
jorgebucaran pushed a commit that referenced this pull request Jan 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants