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
@cycle/dom 10.0.0-rc17 typing problems #307
Comments
In this case, I believe that the typings would have to be written by hand, one for each function, e.g.:
causes the typescript compiler to complain in
Let me know if I can supply more information, or if I can help out. |
Thank you for all the reports. They will be investigated :) |
Regarding 7 I've generally used |
Regarding 4 - events() has to return any, because it does not specifically return an xstream |
Thanks wmaurer for the detailed reports. These are priority and we will fix them very soon |
Regarding 4 - events() returning any: Another possibility would be to use typescript's generics, so that
Usage would be:
which is much nicer than:
|
Nice suggestions indeed! |
Just ran into this. The way I got around the lack of typings was to do: import { run } from '@cycle/rxjs-run';
import { makeDOMDriver } from '@cycle/dom/src/index.ts';
import { DriverFunction } from '@cycle/base';
...
run(main, {
DOM: (makeDOMDriver('body') as DriverFunction)
}); edit: that only got me so far before it complained about snabbdom |
After being built, none of the individual tag hyperscript-helper functions are being exported in Also those same tag helpers are currently exported from |
Regarding 4) Unfortunately, my second suggestion won't work. I now see that Typescript doesn't yet support higher-kinded types. I think the only way to do this is to supply sets of typings specifically for RxJS or xstream. But this implies that every driver would need a set of typings for each stream library, which is a bit of a pain ... I do have a general suggestion regarding typings. Rather than exporting typings as classes, I would suggest exporting interfaces which describe the public API of the library.
I believe this will help with using open-ended interfaces (which I don't think works with classes) ** I intentionally used the |
Fixes one issue of cyclejs/cyclejs#307
@wmaurer I started solving these issues. Can you help clarify why and how did you perceive this problem?
As far as I can see, this shouldn't be perceived. Or is it a problem that Cycle.run should know how to receive any function as a driver? |
@staltz thanks for starting to work on this
As a result, the typescript compiler gives me the following error: If the intention is that
|
Yes, correct, thanks for the feedback, and I think your last paragraph is the right course of action. |
@TylorS do you have an idea how to solve (6)? |
I think we could have a reference tag to custom-typings/main.d.ts in the index.d.ts ? |
@TylorS Ah yes. That's what's missing. |
@staltz Unfortunatelly this does not works, just installed 10.0.0-rc23 but when running tsc 1.8.10 I am getting
|
I'm working on it... |
@wmaurer @fenduru @ntilwalli @mattiamanzati can you try and see if DOM 10.0.0-rc26 fixes your issues? All issues except number (4) should be fixed, and I put out an example using TypeScript: https://github.com/cyclejs/examples/tree/diversity/bmi-typescript |
@staltz Yep! I confirm that with tsc or ts-loader fixes all the problems! |
Ok, good news! I'll close this issue, but we can still comment here, of course. If we have more TS issues, we can open other issues. |
Hi @staltz, sorry for not replying earlier - been busy with family and work ... Do you have any ideas for fixing (4)? I could imagine having a some xstream specific typings for cycle/dom. I placed the following in my app's
(... though to do this I really need Should I open a new issue to continue discussing the possibilities to solve (4)? |
Yes, lets open a new issue for that, and I have some ideas for solving it. |
Ok, I'll kick it off ... |
I've come across a number of problems when building a new cycle / xstream based app using typescript.
Cannot find module '@cycle/dom'
: the typings are not found at all by the typescript compiler.Solution: add the following line to
@cycle/dom
'spackage.json
:makeDOMDriver
returns incorrect typeFunction
. It should instead, returnDriverFunction
Too few interfaces are exported from
index.d.ts
. For example, I would like to use the interfaceDOMSource
, so that I can definemain
as follows:This way, I would have edit-time intellisense in VSCode (or Atom with atom-typescript)
However,
DOMSource
is not exported fromindex.d.ts
.DOMSource.events()
returnsany
, which means the subsequentxstream
methods and operators are not type checked.DOMSource.events()
should have return typeStream<Event>
Having this issues fixed for the next RC would be very helpful.
The text was updated successfully, but these errors were encountered: