-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript support #9
Conversation
@joseluisq thanks for the pull request! 🍻 Unfortunately this project does not use TypeScript and was written in pure JavaScript for simplicity. As a single maintainer I don't feel like I can commit to maintaining these typings over time. I appreciate the work you put into creating them to begin with, but stale typings seem inevitable as I make changes to the codebase given my lack of familiarity with TypeScript. Please resubmit typings to DefinitelyTyped repo. I'd be happy to add a mention in the readme linking to your submission for other developers who want to find them. |
Sure, I understand your reasons.
Yeah, I will try to redirect it to DefinitelyTyped because in my company we use Typescript and have chosen Hyperapp (for several reasons) and typings support. So I thought it's not a bad idea to add typings for |
@joseluisq I completely understand @frenzzy point of view! The good news is that a future version after V2 may include built-in support for renderToString, then I'd be happy to include your typings in the main repo. Until then! 🙇 |
Sounds great 👍 At the moment, I have prefered to add above Complementing what it already explained on this thread, it would be great if Hyperapp could maintain typings more consistent across the @hyperapp organization in coming releases. |
@joseluisq This is difficult to do because few of us actually use TS, but I'm going to try more! 💪 |
Sure, I could contribute if you need an extra hand ⚡️ |
Btw, I don't mind to add typings to this repo if you are going to maintain them in the future :) |
Happy to hear about it! Let me know how can I help 💯 |
@@ -0,0 +1,47 @@ | |||
export as namespace render | |||
|
|||
import { ActionsType, View } from 'hyperapp' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this requires hyperapp
to be in dependencies or peer/dev deps are enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this requires hyperapp to be in dependencies or peer/dev deps are enough?
yep, withRender(nextApp)
needs ActionsType
and View
types.
test/ts/tsconfig.json
Outdated
"jsxFactory": "h", | ||
"baseUrl": "../..", | ||
"typeRoots": [ | ||
"node_modules/@types/node/index.d.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this also requires @types/node
to be in deps? Tests are not passing...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, because renderToStream(view, state, actions) returns an Readable stream object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me review the tests again...
- add @types/node - hyperapp
Codecov Report
@@ Coverage Diff @@
## master #9 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 3 3
Lines 91 91
Branches 18 18
=====================================
Hits 91 91 Continue to review full report at Codecov.
|
@jorgebucaran or maybe it is better to publish Otherwise it requires to add all typings dependencies to the project and users have to install them even if they do not use typescript =/ All popular projects have typings in DefinitelyTyped by similar reasons, like |
I'd prefer to provide working types out of the box, like we do in Hyperapp. I think it's okay to take in @joseluisq changes once you are satisfied and if we run into issues in the future, e.g., when you want to change something in @hyperapp/render, you should just not forget to mention José so he can have a look. I used to be more hesitant about TS in the past, but I think it's worth the trouble. If we can avoid forcing TS users to install another dep to add types, is a win for us. |
yep, so if you want to work with Typescript you can install typings on demand. |
@jorgebucaran right, I guess that v2 can address this on in the future. |
In addition, Feel free to notify me or add me as reviewer. |
Yes, but how to install dependencies with typings "on demand" but not always? Will moving them to Also would be cool to support Node.js since v6. So, can we use |
On demand typings only if you package is in DefinitelyTyped or another repo.
You right about peerDeps, it will be better to move deps to peerDeps, so users can install typings (even node versions) that they want. |
@joseluisq great job, thanks!
FYI, at the moment npm throws a warning when a peer dependency is omitted: npm WARN @hyperapp/render@2.0.0 requires a peer of @types/node@>=6.x but none is installed. You must install peer dependencies yourself. Personally I think this is not cool because it sounds like a mandatory, but it is more like npm related issue: npm/npm#20646 |
Exactly, looks not good for So, you keep out TS Devs of your codebase. (joke 😅) |
}, | ||
"scripts": { | ||
"lint": "eslint benchmark src test tools", | ||
"test": "jest", | ||
"test": "jest --coverage --no-cache && tsc -p test/ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need --no-cache
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure. jestjs/jest#6610
Cheers! 🥇 |
I made some corrections here: #10 |
Sure, reviewing... |
@@ -0,0 +1,47 @@ | |||
export as namespace render |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What the convention do we have render
or hyperappRender
? See okwolf/hyperapp-logger#18
Looks like we agreed to use window.hyperappRender
should this namespace be the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I see that you agreed at okwolf/hyperapp-logger#18 to prefer hyperappLogger
instead of logger
.
So we should follow the same convention, something like hyperappRender
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sent a PR about this addressed at #11
Released as v2.1.0 🎉 |
Cheers! 🍻 |
Types of changes
Checklist: