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

Generic emitters #5

Open
devanshj opened this issue Jul 27, 2020 · 1 comment
Open

Generic emitters #5

devanshj opened this issue Jul 27, 2020 · 1 comment
Labels
typescript-limitation Can't fix/improve because of TypeScript limitations

Comments

@devanshj
Copy link
Owner

devanshj commented Jul 27, 2020

fromEmitter({
  on: <T>(x: T, f: (x: T) => void) => {}
  off: (() => {}) as any
})
.event("foo")
// Expected Observable<"foo"> but doesn't work
// because right now we manually check overloads and
// not via inference because typescript doesn't support inference like

type Test = (<T>(x: T) => T) extends ((x: string) => infer U) ? U : never;
// Expected `string` but is `unknown`
@devanshj
Copy link
Owner Author

I can't find the issue on typescript's repo related to this limitation might file a feature-request let's see.

@devanshj devanshj changed the title Add the type parameter limitation in readme Generic emitters Jul 27, 2020
@devanshj devanshj added the typescript-limitation Can't fix/improve because of TypeScript limitations label Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript-limitation Can't fix/improve because of TypeScript limitations
Projects
None yet
Development

No branches or pull requests

1 participant