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

flatten is not inferring type properly #4

Closed
AlexGalays opened this issue Apr 24, 2016 · 2 comments
Closed

flatten is not inferring type properly #4

AlexGalays opened this issue Apr 24, 2016 · 2 comments

Comments

@AlexGalays
Copy link
Contributor

AlexGalays commented Apr 24, 2016

Hello,

Using Typescript 1.8.7,

I have stream.map(fnThatReturnsAStreamOfBooleans). That properly get inferred to Stream<Stream<boolean>>

However, if I finish the chain with flatten(), the final type is Stream<{}> instead of Stream<boolean>

Example:

const stream: Stream<string> = Stream.create({
    start: listener => {},
    stop: () => {}
})

const stream2: Stream<boolean> = Stream.create({
    start: listener => {},
    stop: () => {}
})

const f = stream.map(x => stream2).flatten()

f is a stream<{}>

I suspect the T in flatten completely redefines the T of the Stream.

I think it would be best to remove this whole T extends Stream<R> for now.

PS: this seems to be related: microsoft/TypeScript#1290

Arguably, this shows a single operation flatMap is not such a bad idea after all :p

@staltz
Copy link
Owner

staltz commented Apr 25, 2016

Thanks for the report

staltz added a commit that referenced this issue Apr 29, 2016
staltz added a commit that referenced this issue Apr 30, 2016
staltz added a commit that referenced this issue Apr 30, 2016
@staltz
Copy link
Owner

staltz commented Apr 30, 2016

Fixed in 2.1.0

@staltz staltz closed this as completed Apr 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants