Skip to content

Instantly share code, notes, and snippets.

@zerobias
Last active January 25, 2018 09:48
Show Gist options
  • Save zerobias/e386e0ea5d0773f589d3d6c6fe8c7426 to your computer and use it in GitHub Desktop.
Save zerobias/e386e0ea5d0773f589d3d6c6fe8c7426 to your computer and use it in GitHub Desktop.
More effective flow typings
[options]
module.name_mapper='^most-subject$' -> '<PROJECT_ROOT>/most-subject'

Example project for typed library which uses external Stream type

You can try this example with

yarn add https://gist.github.com/e386e0ea5d0773f589d3d6c6fe8c7426.git
npm install https://gist.github.com/e386e0ea5d0773f589d3d6c6fe8c7426.git
import {foo} from 'better-flow-typings-example'

foo.next('bar')
//@flow
import {sync, type Subject} from 'most-subject'
export const foo: Subject<'bar'> = sync()
foo.next('bar')
//@flow
import type {Subject} from './most-subject'
declare export var foo: Subject<'bar'>
//@flow
/* eslint-disable no-unused-vars */
import {Stream} from 'most'
declare export
class Subject<T> extends Stream<T> {
next(value: T): Subject<T>,
}
declare export
function sync<T>(): Subject<T>
declare export
function async<T>(): Subject<T>
{
"name": "better-flow-typings-example",
"version": "0.0.1",
"description": "",
"main": "index.js",
"dependencies": {
"most": "^1.7.2",
"most-subject": "5.3.0"
},
"devDependencies": {
"flow-bin": "^0.63.1"
},
"author": "Zero Bias",
"license": "MIT",
"private": true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment