cujojs / most

Ultra-high performance reactive programming
MIT License
3.49k stars 231 forks source link

transduce() is missing from the type definition #512

Open jeffrose opened 6 years ago

jeffrose commented 6 years ago

Summary

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

Versions

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 commented 6 years ago

It looks like thru may be missing as well.

briancavalier commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Sorry about the false alarm.

No worries @jeffrose.

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