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

Chaining data types between streams #40

Open
piglovesyou opened this issue Mar 21, 2021 · 0 comments
Open

Chaining data types between streams #40

piglovesyou opened this issue Mar 21, 2021 · 0 comments

Comments

@piglovesyou
Copy link
Owner

What's expected

The argument types should be inferred by the previous stream.

pipeline(
    Readable.from([2, 3, 4]),
    pipe(n => {
      n as number // Typed as number
      return `${n} is coming!`
    }),
    pipe(message => {
      message as string // Typed as string
      return { message }
    }),
    pipe(obj => {
      obj as { message: string} // Typed as { message: string}
    }),
    (err) => {}
)

Problem

Node's ReadableStream/WritableStream/ReadWriteStream are not typed. DefinitelyTyped/DefinitelyTyped#45196 and DefinitelyTyped/DefinitelyTyped#45222 tackled it, but it seems difficult to modify the base types that many other modules depend on.

Possible solution

It could be controversial, but how about providing additional types by Declaration Merging only for pipeline-pipe users? We have to give up third-party transformers lose types, but we may be able to type our pipe() and the other utilities.

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

1 participant