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

transduce() is missing from the type definition #512

Open
jeffrose opened this issue Dec 20, 2017 · 4 comments
Open

transduce() is missing from the type definition #512

jeffrose opened this issue Dec 20, 2017 · 4 comments

Comments

@jeffrose
Copy link

Summary

The transduce() method is missing from the type definition and is therefore invisible to TypeScript.

Versions

  • most.js: 1.7.2
  • typescript: 2.6.2

Steps to reproduce

  1. Import the transduce method from most or import all of most and use the transduce method

Code to reproduce

Doing...
import { transduce } from 'most';
... will result in the error...
[ts] Module '".../node_modules/most/type-definitions/most"' has no exported member 'transduce'.

Doing...

import * as most from 'most';
most.transduce( transducer );

... will result in the error...
[ts] Property 'transduce' does not exist on type 'typeof ".../node_modules/most/type-definitions/most"'.

@jeffrose
Copy link
Author

It looks like thru may be missing as well.

@briancavalier
Copy link
Member

Thanks @jeffrose. transduce does indeed seem to be missing--sorry about that. Do you know if it's possible to write a type definition for a transducer that is agnostic of the particular transducer library? Any interest in sending a PR for it?

I verified thru is there for both TS and Flow. It only exists as a method, since it's job is to adapt functions to method chaining style.

@jeffrose
Copy link
Author

You're right about thru(). I was simply looking for it in the wrong place. Sorry about the false alarm.

While I have experience with both individually, I only recently started working with transducers and TypeScript together.

I've seen some rather robust definitions like in transducist...
https://github.com/dphilipson/transducist/blob/master/src/index.ts#L11-L42

But I assume most could get away with something more simplistic like in ramda...
https://github.com/types/npm-ramda/blob/master/templates/%24types.d.ts#L77-L87

These get used by ramda's transduce() and into() methods...
https://github.com/types/npm-ramda/blob/master/templates/transduce.d.ts
https://github.com/types/npm-ramda/blob/master/templates/into.d.ts

As long as the library as followed the protocol, it should work. I have similar interfaces and types declared locally but I have not put them to the test yet. If I get something more battle-tested, I will look at doing a PR.

@briancavalier
Copy link
Member

Sorry about the false alarm.

No worries @jeffrose.

Thanks for the links. I hope to take a look at them over the holiday.

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

2 participants