You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Actually, I've already put some work into creating a TypeScript definition file so I could get intellisence, code completion, refactoring, etc. in IDE's that understand t.ds (TypeScript definition files). But that was for a much earlier version 0.0.8. A lot has changed. 🎢 A TypeScript declaration file is for use with JavaScript. As the user types, he/she gets information about a method's call signature, expected parameters, and the parameter's types. It will also show basically whatever documentation you provide for that in the IDE. It's a very helpful feature when you're not familiar with an API. Once I know an API, I dispense with it. Here's a video about intellisense
That said, it doesn't make sense to deal with typings until you have a fairly stable API. That's why I stopped working on my t.ds. Things were changing to quickly so 🏖
By the way, I've written a number of TypeScript definition files and contributed to definitelytyped.org. I've got about 80,000 lines of TypeScript under my belt. But I'm currently just doing ES6.
Reacted by Charlike Mike Reagent, Vien Luong and Max Milton
No probs. I'd probably just make a fork for that. Hardest part doing the original one was discerning the return types in a few places. Geez, seems that always the hardest part of creating a typings file 🤔
We'd want to also put together a typings test to run against actual code. You have to use every feature so that the TypeScript compiler and test types in all possible situations. It doesn't usually take that much code to pull that off.
Just let me know when you feel you have your feature set stable. One thing, the plumbing can change quite a bit without affecting the public type interface, as long as call signatures and return types remain the same. Something to be aware of when you decide when you want to introduce types.
It would be really cool if my IDE/Editor could autocomplete app's props as one types. I think that's one of the cool merits that come with adding typings.
Give me a ping out whether you're looking to convert or just add .d.ts files. We're planning on making a few utilities available for easily testing type declarations.
Is there any ongoing work on this? I have a TypeScript project and I'm considering using hyperapp for the UI due to its similarity to the Elm Architecture.
@jbucaran, I haven't written any typings either, but I'm considering learning it. Maybe @rbiggs can help, since he said he has experience with the process.
@Swizz, I just tried the following and it seems to have good results:
interfaceActionsObject<State>{[prop: string]: ((state: State)=>State)|ActionsObject<State>}interfaceVNode{tag: string;data: any;children: HyperStateChild;}typeHyperStateChild=string|VNode|HyperStateChildrenArray;interfaceHyperStateChildrenArrayextendsArray<HyperStateChild>{}interfaceOptions<State,Actions>{state?: State;view?: (state: State,actions: Actions)=>VNode;actions?: Actions;}declarefunctionh(tag: string,data?: any, ...children: HyperStateChild[]): VNode;declarefunctionapp<State,ActionsextendsActionsObject<State>,>(obj: Options<State,Actions>): void;app({state: {us: "no strangers to love",you: "know the rules and so do I"},actions: {foo: {bar: s=>s}},view: (s,a)=>h("div")});
However, there seems to be a problem with this when both noImplicitAny and strictNullChecks are used together, so I filed this issue. A workaround is just to tell users to turn off one, or make actions non-optional.
I want to advise on this matter. If you're willing to put .d.ts files into your repo, you should feel confident that you know how to work with and support these files, and that you're willing to roll out a patch release if something is incorrect with them. The same goes with something like .js.flow files as well, or anything similar.
If you're not comfortable with that, the best course of action is probably to send the .d.ts files to DefinitelyTyped and have an active hand in the quality/accuracy of them, possibly. There are a bunch of other benefits to using DefinitelyTyped too. For example, we can test all type declarations that depend on each other if they reside in DefinitelyTyped to understand potential breakages.
The alternative solution is to author in TypeScript and worry less about synchronizing the .d.ts and .js files.
I aimed to be as close as possible to the API documentation, because guys made all the job here.
I know I am against the TS styleguide with lowercase type/interface but first I wanted to translate the API documentation.
But your one inspire me a lot of things to make the declaration even simplier.
The major issue is Hyperapp is still in active development and its API could change at any time. Maintain a DefinitelyTyped declaration will be a mess. It could be more easy to have a kind a test who check declaration file against breaking changes. And an active TS dev to fix it in any PR.
I'm against writing code in TypeScript. It would force certain checks which would increase bundle size (or a bunch of casting which will just make the code ugly and lose the purpose of TypeScript).
The library is super-small and with proper documentation (which we have), I don't think we need a transpiler step. A lot of code is already optimized by hand.
I guess .d.ts files could be tested by writing a "fake consumer" test in TypeScript, which would fail compile-time if the API changed and definitions are not updated?
@Swizz The existing APIs will definitely not change at this point. Some stuff may get deleted (or added), but things like the function signature (state, actions, data, emit) is certain not to change.
EDIT: Having said that, I don't think stuff will get added, other than components, assuming those happen (I hope).
actions may not return a State but a subset of it (which is then merged with the state). If I am not wrong, a subset of an object in TypeScript can be modeled using Pick<T>.
Events: it can contain custom events, not just loaded, render etc... So I think it should be modeled as a map.
we also need to redefine the JSX namespace in order to enable the jsx syntax (aka .tsx). I tried the react one but event handlers don't match with HyperApp actions. But I guess we can predate and adapt @types\react.
Activity
rbiggs commentedon Feb 14, 2017
Actually, I've already put some work into creating a TypeScript definition file so I could get intellisence, code completion, refactoring, etc. in IDE's that understand t.ds (TypeScript definition files). But that was for a much earlier version 0.0.8. A lot has changed. 🎢 A TypeScript declaration file is for use with JavaScript. As the user types, he/she gets information about a method's call signature, expected parameters, and the parameter's types. It will also show basically whatever documentation you provide for that in the IDE. It's a very helpful feature when you're not familiar with an API. Once I know an API, I dispense with it. Here's a video about intellisense
That said, it doesn't make sense to deal with typings until you have a fairly stable API. That's why I stopped working on my t.ds. Things were changing to quickly so 🏖
By the way, I've written a number of TypeScript definition files and contributed to definitelytyped.org. I've got about 80,000 lines of TypeScript under my belt. But I'm currently just doing ES6.
jorgebucaran commentedon Feb 14, 2017
Thanks for the clarification @rbiggs! 👍
Awesome! Please help me create the typings when the API has stabilized. Let's keep this issue open until then.
rbiggs commentedon Feb 14, 2017
No probs. I'd probably just make a fork for that. Hardest part doing the original one was discerning the return types in a few places. Geez, seems that always the hardest part of creating a typings file 🤔
rbiggs commentedon Feb 14, 2017
We'd want to also put together a typings test to run against actual code. You have to use every feature so that the TypeScript compiler and test types in all possible situations. It doesn't usually take that much code to pull that off.
rbiggs commentedon Feb 14, 2017
Just let me know when you feel you have your feature set stable. One thing, the plumbing can change quite a bit without affecting the public type interface, as long as call signatures and return types remain the same. Something to be aware of when you decide when you want to introduce types.
jorgebucaran commentedon Feb 14, 2017
@rbiggs I will, thanks! I'll probably create a
typingsbranch, push some stuff there and asked you to take a look. 👍jorgebucaran commentedon Feb 27, 2017
It would be really cool if my IDE/Editor could autocomplete app's props as one types. I think that's one of the cool merits that come with adding typings.
DanielRosenwasser commentedon Mar 21, 2017
Give me a ping out whether you're looking to convert or just add
.d.tsfiles. We're planning on making a few utilities available for easily testing type declarations.jorgebucaran commentedon Mar 21, 2017
Hi @DanielRosenwasser, not convert, but add a .d.ts file. Similar to https://github.com/developit/mitt/blob/master/mitt.d.ts perhaps.
LucianU commentedon Apr 13, 2017
Is there any ongoing work on this? I have a TypeScript project and I'm considering using hyperapp for the UI due to its similarity to the Elm Architecture.
jorgebucaran commentedon Apr 13, 2017
@LucianU Now that 0.8.0 is out, it might be a good time to start working on it. I am not familiar with the process so any help is welcome.
LucianU commentedon Apr 14, 2017
@jbucaran, I haven't written any typings either, but I'm considering learning it. Maybe @rbiggs can help, since he said he has experience with the process.
Swizz commentedon Jun 28, 2017
Naive declaration file based on the API doc. On a gist to facilitate discussion about it
https://gist.github.com/Swizz/964c027075168b1ad8a66fd4fee6a0cc
jorgebucaran commentedon Jun 29, 2017
@Swizz Can you open a PR with this?
1 remaining item
DanielRosenwasser commentedon Jun 29, 2017
@Swizz, I just tried the following and it seems to have good results:
However, there seems to be a problem with this when both
noImplicitAnyandstrictNullChecksare used together, so I filed this issue. A workaround is just to tell users to turn off one, or makeactionsnon-optional.DanielRosenwasser commentedon Jun 29, 2017
I want to advise on this matter. If you're willing to put
.d.tsfiles into your repo, you should feel confident that you know how to work with and support these files, and that you're willing to roll out a patch release if something is incorrect with them. The same goes with something like.js.flowfiles as well, or anything similar.If you're not comfortable with that, the best course of action is probably to send the
.d.tsfiles to DefinitelyTyped and have an active hand in the quality/accuracy of them, possibly. There are a bunch of other benefits to using DefinitelyTyped too. For example, we can test all type declarations that depend on each other if they reside in DefinitelyTyped to understand potential breakages.The alternative solution is to author in TypeScript and worry less about synchronizing the
.d.tsand.jsfiles.Swizz commentedon Jun 29, 2017
I aimed to be as close as possible to the API documentation, because guys made all the job here.
I know I am against the TS styleguide with lowercase type/interface but first I wanted to translate the API documentation.
But your one inspire me a lot of things to make the declaration even simplier.
The major issue is Hyperapp is still in active development and its API could change at any time. Maintain a DefinitelyTyped declaration will be a mess. It could be more easy to have a kind a test who check declaration file against breaking changes. And an active TS dev to fix it in any PR.
lazarljubenovic commentedon Jun 29, 2017
I'm against writing code in TypeScript. It would force certain checks which would increase bundle size (or a bunch of casting which will just make the code ugly and lose the purpose of TypeScript).
The library is super-small and with proper documentation (which we have), I don't think we need a transpiler step. A lot of code is already optimized by hand.
I guess
.d.tsfiles could be tested by writing a "fake consumer" test in TypeScript, which would fail compile-time if the API changed and definitions are not updated?jorgebucaran commentedon Jun 29, 2017
@Swizz The existing APIs will definitely not change at this point. Some stuff may get deleted (or added), but things like the function signature
(state, actions, data, emit)is certain not to change.EDIT: Having said that, I don't think stuff will get added, other than components, assuming those happen (I hope).
Swizz commentedon Jun 29, 2017
Just updated the gist with more Generics 🎉
https://gist.github.com/Swizz/964c027075168b1ad8a66fd4fee6a0cc
Works well with
noImplicitAnyandstrictNullChecks.Swizz commentedon Jun 29, 2017
If there is no objections, I will start to work on a PR 👍
nippur72 commentedon Jul 3, 2017
two things to note:
Statebut a subset of it (which is then merged with the state). If I am not wrong, a subset of an object in TypeScript can be modeled usingPick<T>.Events: it can contain custom events, not justloaded,renderetc... So I think it should be modeled as a map.jorgebucaran commentedon Jul 4, 2017
If anyone can open a PR we could continue the discussion there and close here. 👋🤔
Swizz commentedon Jul 4, 2017
Yeap, I was waiting, some PR to be closed, Regarding #266 #259
I will make a PR within day. After documenting on @nippur72 suggestions.
nippur72 commentedon Jul 4, 2017
we also need to redefine the
JSXnamespace in order to enable the jsx syntax (aka.tsx). I tried thereactone but event handlers don't match with HyperApp actions. But I guess we can predate and adapt@types\react.Swizz commentedon Jul 4, 2017
I am on it, with JSX support (in naive way, btw) 😄
https://github.com/Swizz/hyperapp/blob/typing/hyperapp.d.ts
I am ready to PR after few more tests ; but no solutions about Events yet.
edit :
is not correct, the correct one is
edit2 :
No, it is not, I was correct on the first try 👍
jorgebucaran commentedon Jul 16, 2017
Closing in favor of #279.