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

Typings error #342

Open
rwpino opened this issue Oct 14, 2016 · 5 comments
Open

Typings error #342

rwpino opened this issue Oct 14, 2016 · 5 comments

Comments

@rwpino
Copy link

rwpino commented Oct 14, 2016

I get this typescript error

node_modules/most/type-definitions/most.d.ts(223,85): error TS2304: Cannot find name 'Event'.

as a temporary fix I changed it for the following

export function fromEvent(event: string, target: any, useCapture?: boolean): Stream;

Another issue I have is with type definition for recoverWith

recoverWith(p: (a: B) => Stream): Stream;

this is forcing me to write

recoverWith((error: Error) => of(of({ type: "error", value: error.message })))

I guess the correct one would be

recoverWith(p: (a: B) => A): Stream;

@TylorS
Copy link
Collaborator

TylorS commented Oct 15, 2016

Hi @rwpino, would you be so kind to relay which version of TypeScript are you using?

@rwpino
Copy link
Author

rwpino commented Oct 15, 2016

Hi @TylorS . I'm using the version 1.8.10

@TylorS
Copy link
Collaborator

TylorS commented Oct 15, 2016

As a more correct solution to your first issue, I believe TypeScript 1.8 also has the option, but I know TypeScript 2.x does have it. If I'm incorrect let me know we can figure out something else :)

// tsconfig.json
{
  "compilerOptions": {
    "lib": [
      "dom" // will add Types for the DOM
    ]
  }
}

As for the second issue you're having, the current type

recoverWith<B>(p: (a: B) => Stream<A>): Stream<A>;

is correct as it corresponds to the current implementation of the function recoverWith(). I'm curious why you would need to have recoverWith return a Stream containing a Stream in the first place. Are you placing it before a switch() or join() ?

@M-Pixel
Copy link

M-Pixel commented Mar 4, 2017

I ran into this as well, because I can't use dom because of other constraints.
I started a fork of this repo for supporting such environments, but am not sure what this repository's protocol is for unit testing or publishing to NPM: #416

@acchou
Copy link

acchou commented Dec 30, 2017

Consider adding:

interface Event {}

to most.d.ts. TypeScript will do declaration merging when the dom library is used, and when it's not then everything should type check properly and there won't be runtime problems unless you actually call fromEvent.

React does something like this as well, see: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/global.d.ts

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

4 participants