Skip to content
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

Returned value of makeHTTPDriver() doesn't typecheck when passed two arguments #970

Open
Javran opened this issue May 29, 2021 · 3 comments

Comments

@Javran
Copy link

Javran commented May 29, 2021

Code to reproduce the issue:

for @cycle/http:

http = makeHTTPDriver()(request$, 'fooHttp')

Expected behavior:

This should typecheck.

Actual behavior:

This doesn't typecheck as makeHTTPDriver() returns a function expecting exactly one argument but passed two instead.

Versions of packages used:

@cycle/[email protected]

For anyone come across this, my current workaround is to give drive a more accurate type:

 const driver: ((stream: Stream<RequestInput>, name?: string) => HTTPSource) =
      (makeHTTPDriver() as any)
 http = driver(request$, 'fooHttp')
@Javran Javran changed the title makeHTTPDriver doesn't typecheck when passed two arguments Returned value of makeHTTPDriver() doesn't typecheck when passed two arguments May 29, 2021
@staltz
Copy link
Member

staltz commented May 30, 2021

Hi @Javran, could you share a bit more of the surrounding context where you are using this? In the vast majority of use cases, the driver function itself shouldn't be called directly, but it's Cycle.js run which calls the driver, and the types in @cycle/http are optimized to satisfy @cycle/run's typechecking when calling run.

@Javran
Copy link
Author

Javran commented May 30, 2021

@staltz I'm trying to have a working starter template project with typescript setup (btw frustratingly, there aren't many around and all of them are bitrot one way or another) and came across https://github.com/cyclejs-community/typescript-starter-cycle/blob/c47fbd5a3a54fe3f5627e4a0bbce86223b101b99/src/drivers/github.ts#L43 (which is the context here) while trying to update the dependencies to latest version. Admittedly I don't know much about cyclejs (yet!), so I'm just following the type to see what's going on.

@jvanbruegge
Copy link
Member

I've briefly looked over the code and the github source is not how one would write this today. Usually you would write a main wrapper similar to @cycle/state that just uses the normal http driver. At the moment sadly do not have the time to change that repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants