Stemming from https://github.com/ReactiveX/rxjs/issues/1742, I'd love to get really great flow definitions. There are some basic ones in https://github.com/flow-typed/flow-typed/blob/master/definitions/npm/rxjs_v6.x.x/flow_v0.34.x-/rxjs_v6.x.x.js. However, there are missing ones (see https://github.com/flow-typed/flow-typed/issues/2285).
I would prefer that they match the source material as much as possible so I followed https://github.com/ReactiveX/rxjs/issues/1742#issuecomment-367831119 as best I could to convert typescript to flow using flowgen. All I got was a stream of Missing node parse ExportDeclaration errors. 😠Here's the code I used:
Open me for sample code
// Run as
// $ node genDefs.js
/**
* Converts typescript definitions for RxJS to Flow
*/
const flowgen = require('flowgen')
const { compiler } = flowgen.default
/**
$ ls node_modules/rxjs/*.ts
node_modules/rxjs/AsyncSubject.d.ts node_modules/rxjs/Rx.d.ts
node_modules/rxjs/BehaviorSubject.d.ts node_modules/rxjs/Scheduler.d.ts
node_modules/rxjs/InnerSubscriber.d.ts node_modules/rxjs/Subject.d.ts
node_modules/rxjs/Notification.d.ts node_modules/rxjs/SubjectSubscription.d.ts
node_modules/rxjs/Observable.d.ts node_modules/rxjs/Subscriber.d.ts
node_modules/rxjs/Observer.d.ts node_modules/rxjs/Subscription.d.ts
node_modules/rxjs/Operator.d.ts node_modules/rxjs/index.d.ts
node_modules/rxjs/OuterSubscriber.d.ts node_modules/rxjs/interfaces.d.ts
node_modules/rxjs/ReplaySubject.d.ts
*/
const filename = "node_modules/rxjs/index.d.ts"
const flowdef = compiler.compileDefinitionFile(filename);
console.log(flowdef)
Would there be a way for us to maintain the flow definitions inside of rxjs and potentially generate them based on the typescript definitions?
If someone can propose solutions to build flow defs from our typescript definitions, it'll work for us. We probably can't hand-craft it I guess.
It's been suggested to use https://github.com/joarwilk/flowgen to generate them. So long as the interface is staying the same though, we could hand write and curate them in this repository with contributors.
we could hand write and curate them in this repository with contributors
I would probably against it, unfortunately. similar to defnintelytyped, handcrafed interfaces doesn't backed by original codebase (i,e ts->dts) hosted in original code relying on contributor's effort is highly fragile and I believe it should be territory of flow-typed intended for. If type need to be hand crafted and contributor need to make changes, what makes different if those PR goes to flow-typed. vs. core repo?
I would be +1 if there is 1. way to generate flowtype bindings from either source code or type definitions generated 2. way to validate if it's correspond to typescript def (maybe somthing similar to dtslint does). If we lacks of one of it, I don't think core can include it in package as type definition breaking is mostly can be major semver breaking changes.
I'd be extremely happy to contract (pay $$$) to have the flow typed definitions brought up to speed with current RxJS, whether they live in flow-typed or inside this repository.
I updated the flow types to mirror the current typescript definitions. Checkout https://github.com/flow-typed/flow-typed/pull/2855
Sorry @rgbkrk but let me close this issue for now as we don't have much actionable at this moment - it doesn't mean we won't have this forever though. Anyone interested in this issue, feel free to create new issue with proposal meet requirement:
No worries, we both:
flow-typed¯\_(ツ)_/¯
Most helpful comment
I updated the flow types to mirror the current typescript definitions. Checkout https://github.com/flow-typed/flow-typed/pull/2855