From d9042e79aeb3e2c0ba66e311b64a92cf9d05240c Mon Sep 17 00:00:00 2001 From: Ivan Starkov Date: Thu, 19 Apr 2018 11:09:28 +0300 Subject: [PATCH] Include flow types into library (#649) * Fix types for modern flow * Move flow declarations and test into recompose * Fix docs * Remove errors * Add yarn-error to gitignore * Append flow 2 test * Update release to support flow types * Remove unneeded command --- types/flow-typed/.flowconfig => .flowconfig | 4 +- .gitignore | 1 + .prettierignore | 2 + README.md | 4 +- docs/flow.md | 92 ++++++ package.json | 5 +- scripts/release.js | 14 +- .../recompose/__tests__/types}/test_branch.js | 4 +- .../types}/test_classBasedEnhancer.js | 4 +- .../types}/test_componentFromStream.js | 2 +- .../types}/test_createEventHandler.js | 2 +- .../__tests__/types}/test_defaultProps.js | 4 +- .../types}/test_functionalEnhancer.js | 4 +- .../__tests__/types}/test_getContext.js | 4 +- .../__tests__/types}/test_mapProps.js | 4 +- .../__tests__/types}/test_mapPropsStream.js | 4 +- .../types}/test_onlyUpdateForKeys.js | 4 +- .../types}/test_onlyUpdateForPropTypes.js | 4 +- .../recompose/__tests__/types}/test_pure.js | 4 +- .../__tests__/types}/test_shouldUpdate.js | 4 +- .../__tests__/types}/test_statics.js | 4 +- .../__tests__/types}/test_toClass.js | 4 +- .../recompose/__tests__/types}/test_utils.js | 4 +- .../recompose/__tests__/types}/test_voodoo.js | 4 +- .../__tests__/types}/test_withContext.js | 4 +- .../__tests__/types}/test_withHandlers.js | 10 +- .../__tests__/types}/test_withProps.js | 4 +- .../types}/test_withPropsOnChange.js | 4 +- .../types}/test_withStateHandlers.js | 9 +- src/packages/recompose/index.js.flow | 262 +++++++++++++++++ types/flow-typed/README.md | 13 - types/flow-typed/package.json | 15 - .../flow_v0.55.x-/recompose_v0.24.x.js | 270 ------------------ types/flow-typed/yarn.lock | 104 ------- yarn.lock | 4 + 35 files changed, 430 insertions(+), 455 deletions(-) rename types/flow-typed/.flowconfig => .flowconfig (53%) create mode 100644 .prettierignore create mode 100644 docs/flow.md rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_branch.js (98%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_classBasedEnhancer.js (93%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_componentFromStream.js (80%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_createEventHandler.js (84%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_defaultProps.js (89%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_functionalEnhancer.js (90%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_getContext.js (91%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_mapProps.js (87%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_mapPropsStream.js (89%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_onlyUpdateForKeys.js (87%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_onlyUpdateForPropTypes.js (85%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_pure.js (87%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_shouldUpdate.js (90%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_statics.js (94%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_toClass.js (86%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_utils.js (85%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_voodoo.js (98%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_withContext.js (88%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_withHandlers.js (84%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_withProps.js (93%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_withPropsOnChange.js (95%) rename {types/flow-typed/recompose_v0.24.x/flow_v0.55.x- => src/packages/recompose/__tests__/types}/test_withStateHandlers.js (91%) create mode 100644 src/packages/recompose/index.js.flow delete mode 100644 types/flow-typed/README.md delete mode 100644 types/flow-typed/package.json delete mode 100644 types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/recompose_v0.24.x.js delete mode 100644 types/flow-typed/yarn.lock diff --git a/types/flow-typed/.flowconfig b/.flowconfig similarity index 53% rename from types/flow-typed/.flowconfig rename to .flowconfig index 136b07aa..b3727b81 100644 --- a/types/flow-typed/.flowconfig +++ b/.flowconfig @@ -1,11 +1,11 @@ [ignore] +/types/.* [include] [libs] -../flow-typed/recompose_v0.24.x/flow_v0.55.x-/recompose_v0.24.x.js [options] suppress_comment=\\(.\\|\n\\)*\\$ExpectError -[lints] +[lints] \ No newline at end of file diff --git a/.gitignore b/.gitignore index eec1d5f1..2ce20a56 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ release lib coverage .vscode +yarn-error.log diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..4cbee9a2 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +node_modules +package.json \ No newline at end of file diff --git a/README.md b/README.md index 0a05aabf..a68292c9 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Recompose is a React utility belt for function components and higher-order compo npm install recompose --save ``` -**📺 Watch Andrew's [talk on Recompose at React Europe](https://www.youtube.com/watch?v=zD_judE-bXk).** +**📺 Watch Andrew's [talk on Recompose at React Europe](https://www.youtube.com/watch?v=zD_judE-bXk).** *(Note: Performance optimizations he speaks about have been removed, more info [here](https://github.com/acdlite/recompose/releases/tag/v0.26.0))* ### Related modules @@ -159,7 +159,7 @@ const ClassComponent = toClass(FunctionComponent) ## Flow support -[Read the docs](types) +[Read the docs](docs/flow.md) ## Translation diff --git a/docs/flow.md b/docs/flow.md new file mode 100644 index 00000000..63c7406b --- /dev/null +++ b/docs/flow.md @@ -0,0 +1,92 @@ +# Flow support for recompose + +## How it works + +In most cases all you need is to declare a props type of enhanced Component. +Flow will infer all other types you need. + +Example: + +```javascript +import type { HOC } from 'recompose'; + +type EnhancedComponentProps = { + text?: string, +}; + +const baseComponent = ({ text }) =>
{text}
; + +const enhance:HOC<*, EnhancedComponentProps> = compose( + defaultProps({ + text: 'world', + }), + withProps(({ text }) => ({ + text: `Hello ${text}` + })) +); + +export default enhance(baseComponent); + +``` + +See it in action. + +![recompose-flow](https://user-images.githubusercontent.com/5077042/28116959-0c96ae2c-6714-11e7-930e-b1454c629908.gif) + +## How to start + +The easiest way is to start from example. + +Look at [this](http://grader-meets-16837.netlify.com/) app [source](../types/flow-example) + + +## Support + +Type definitions of recompose HOCs are splitted into 2 parts. + +### Part 1 - HOCs with good flow support + +In most cases you can use them without big issues. +Type inference and errors detection works near well. + +These HOCs are: *defaultProps, mapProps, withProps, withStateHandlers, withHandlers, pure, onlyUpdateForKeys, shouldUpdate, renderNothing, renderComponent, branch, withPropsOnChange, onlyUpdateForPropTypes, toClass, withContext, getContext, setStatic, setPropTypes, setDisplayName* + +#### Known issues for "good" HOCs + +see `test_mapProps.js` - inference work but type errors are not detected in hocs + +### Part 2 - other HOCs + +To use these HOCs - you need to provide type information (no automatic type inference). +You must be a good voodoo dancer. + +See `test_voodoo.js` for the idea. + +Some recomendations: + +- *flattenProp,renameProp, renameProps* can easily be replaced with _withProps_ +- *withReducer, withState* -> use _withStateHandlers_ instead +- _lifecycle_ -> you don't need recompose if you need a _lifecycle_, just use React class instead +- _mapPropsStream_ -> see `test_mapPropsStream.js` + +#### Known issues for above HOCs + +See `test_voodoo.js`, `test_mapPropsStream.js` + +### Utils + +*getDisplayName, wrapDisplayName, shallowEqual,isClassComponent, createSink, componentFromProp, nest, hoistStatics.* + +### Articles + +[Typing Higher-order Components in Recompose With Flow](https://medium.com/flow-type/flow-support-in-recompose-1b76f58f4cfc) + +### Faq + +Why to use existential type with `HOC<*, Blbla>` isn't it possible to avoid this? + +*I tried to use type alias but haven't found how to make it work.* + +## Thanks + +Big thanks to [@gcanti](https://github.com/gcanti) for his work on PR [#241](https://github.com/acdlite/recompose/pull/241), it was nice and clear base for current definitions. diff --git a/package.json b/package.json index c3f6d51c..2de897cd 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "license": "MIT", "scripts": { "lint": "eslint scripts src", - "build-recompose": "cross-env PACKAGE_NAME=recompose rollup --config scripts/rollup.config.js", - "test": "jest", + "build:recompose": "cross-env PACKAGE_NAME=recompose rollup --config scripts/rollup.config.js", + "test": "jest && flow", "test:watch": "cross-env BABEL_ENV=cjs jest --watch", "release": "node scripts/release.js", "postinstall": "node scripts/installNestedPackageDeps.js", @@ -60,6 +60,7 @@ "eslint-plugin-jsx-a11y": "^4.0.0", "eslint-plugin-prettier": "^2.0.1", "eslint-plugin-react": "^6.10.3", + "flow-bin": "^0.70.0", "flyd": "^0.2.4", "husky": "^0.13.3", "jest": "^22.4.3", diff --git a/scripts/release.js b/scripts/release.js index 5c139a40..43351591 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -8,6 +8,7 @@ const { flowRight: compose } = require('lodash') const readline = require('readline-sync') const semver = require('semver') const glob = require('glob') +const { pascalCase } = require('change-case') const BIN = './node_modules/.bin' @@ -47,6 +48,8 @@ try { ) } + const libraryName = pascalCase(packageName) + const versionLoc = path.resolve(PACKAGES_SRC_DIR, packageName, 'VERSION') const version = fs.readFileSync(versionLoc, 'utf8').trim() @@ -119,13 +122,18 @@ try { ) log(`Building ${packageName}...`) - const runRollup = () => - `cross-env PACKAGE_NAME:${packageName}` + - ' rollup --config scripts/rollup.config.js' + const runRollup = () => `yarn build:${packageName}` if (exec(runRollup()).code !== 0) { exit(1) } + log(`Preparing ${libraryName}.cjs.js.flow...`) + cp( + '-f', + path.resolve(sourceDir, 'index.js.flow'), + path.resolve(outDir, 'dist', `${libraryName}.cjs.js.flow`) + ) + log(`About to publish ${packageName}@${nextVersion} to npm.`) if (!readline.keyInYN('Sound good? ')) { log('OK. Stopping release.') diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_branch.js b/src/packages/recompose/__tests__/types/test_branch.js similarity index 98% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_branch.js rename to src/packages/recompose/__tests__/types/test_branch.js index 3d02d0c8..e672d17d 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_branch.js +++ b/src/packages/recompose/__tests__/types/test_branch.js @@ -8,9 +8,9 @@ import { renderNothing, renderComponent, onlyUpdateForKeys, -} from 'recompose' +} from '../..' -import type { HOC } from 'recompose' +import type { HOC } from '../..' type EnhancedCompProps = { eA: 1 } diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_classBasedEnhancer.js b/src/packages/recompose/__tests__/types/test_classBasedEnhancer.js similarity index 93% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_classBasedEnhancer.js rename to src/packages/recompose/__tests__/types/test_classBasedEnhancer.js index f1f3abc7..acb143e5 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_classBasedEnhancer.js +++ b/src/packages/recompose/__tests__/types/test_classBasedEnhancer.js @@ -1,7 +1,7 @@ /* @flow */ import * as React from 'react' -import { compose, withProps } from 'recompose' -import type { HOC } from 'recompose' +import { compose, withProps } from '../..' +import type { HOC } from '../..' // Example of very dirty written fetcher enhancer function fetcher( diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_componentFromStream.js b/src/packages/recompose/__tests__/types/test_componentFromStream.js similarity index 80% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_componentFromStream.js rename to src/packages/recompose/__tests__/types/test_componentFromStream.js index 1fd20ed2..a191a9ae 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_componentFromStream.js +++ b/src/packages/recompose/__tests__/types/test_componentFromStream.js @@ -1,6 +1,6 @@ // @flow import React from 'react' -import { componentFromStream } from 'recompose' +import { componentFromStream } from '../..' // $ExpectError componentFromStream(1) diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_createEventHandler.js b/src/packages/recompose/__tests__/types/test_createEventHandler.js similarity index 84% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_createEventHandler.js rename to src/packages/recompose/__tests__/types/test_createEventHandler.js index a0d5f689..0c2a0b49 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_createEventHandler.js +++ b/src/packages/recompose/__tests__/types/test_createEventHandler.js @@ -1,6 +1,6 @@ // @flow import React from 'react' -import { createEventHandler } from 'recompose' +import { createEventHandler } from '../..' // $ExpectError createEventHandler(1) diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_defaultProps.js b/src/packages/recompose/__tests__/types/test_defaultProps.js similarity index 89% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_defaultProps.js rename to src/packages/recompose/__tests__/types/test_defaultProps.js index c77ce961..a44e00e4 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_defaultProps.js +++ b/src/packages/recompose/__tests__/types/test_defaultProps.js @@ -1,9 +1,9 @@ /* eslint-disable no-unused-vars, no-unused-expressions */ /* @flow */ import React from 'react' -import { compose, withProps, defaultProps } from 'recompose' +import { compose, withProps, defaultProps } from '../..' -import type { HOC } from 'recompose' +import type { HOC } from '../..' type EnhancedCompProps = { eA: 1 } diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_functionalEnhancer.js b/src/packages/recompose/__tests__/types/test_functionalEnhancer.js similarity index 90% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_functionalEnhancer.js rename to src/packages/recompose/__tests__/types/test_functionalEnhancer.js index f65d5f57..8660f897 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_functionalEnhancer.js +++ b/src/packages/recompose/__tests__/types/test_functionalEnhancer.js @@ -1,8 +1,8 @@ /* @flow */ import * as React from 'react' -import { compose, withProps } from 'recompose' -import type { HOC } from 'recompose' +import { compose, withProps } from '../..' +import type { HOC } from '../..' function mapProps( mapperFn: EnhancedProps => BaseProps diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_getContext.js b/src/packages/recompose/__tests__/types/test_getContext.js similarity index 91% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_getContext.js rename to src/packages/recompose/__tests__/types/test_getContext.js index c4e9e14d..73dbe446 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_getContext.js +++ b/src/packages/recompose/__tests__/types/test_getContext.js @@ -1,9 +1,9 @@ /* eslint-disable no-unused-vars, no-unused-expressions, arrow-body-style */ /* @flow */ import React from 'react' -import { compose, withProps, getContext } from 'recompose' +import { compose, withProps, getContext } from '../..' // import PropTypes from 'prop-types' -import type { HOC } from 'recompose' +import type { HOC } from '../..' const PropTypes = { number: () => {}, diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_mapProps.js b/src/packages/recompose/__tests__/types/test_mapProps.js similarity index 87% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_mapProps.js rename to src/packages/recompose/__tests__/types/test_mapProps.js index 0a31e3de..388ccdd9 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_mapProps.js +++ b/src/packages/recompose/__tests__/types/test_mapProps.js @@ -2,9 +2,9 @@ /* eslint-disable no-unused-vars, no-unused-expressions, arrow-body-style */ /* @flow */ import React from 'react' -import { compose, mapProps, withProps } from 'recompose' +import { compose, mapProps, withProps } from '../..' -import type { HOC } from 'recompose' +import type { HOC } from '../..' type EnhancedCompProps = { eA: 1 } diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_mapPropsStream.js b/src/packages/recompose/__tests__/types/test_mapPropsStream.js similarity index 89% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_mapPropsStream.js rename to src/packages/recompose/__tests__/types/test_mapPropsStream.js index fc976b42..e87117a8 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_mapPropsStream.js +++ b/src/packages/recompose/__tests__/types/test_mapPropsStream.js @@ -3,9 +3,9 @@ /* @flow */ import React from 'react' // import { Observable } from 'rxjs' -import { compose, mapProps, withProps, mapPropsStream } from 'recompose' +import { compose, mapProps, withProps, mapPropsStream } from '../..' -import type { HOC } from 'recompose' +import type { HOC } from '../..' type EnhancedCompProps = { eA: 1 } diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_onlyUpdateForKeys.js b/src/packages/recompose/__tests__/types/test_onlyUpdateForKeys.js similarity index 87% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_onlyUpdateForKeys.js rename to src/packages/recompose/__tests__/types/test_onlyUpdateForKeys.js index 56e32e00..89be1f70 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_onlyUpdateForKeys.js +++ b/src/packages/recompose/__tests__/types/test_onlyUpdateForKeys.js @@ -1,9 +1,9 @@ /* eslint-disable no-unused-vars, no-unused-expressions */ /* @flow */ import React from 'react' -import { compose, withProps, onlyUpdateForKeys } from 'recompose' +import { compose, withProps, onlyUpdateForKeys } from '../..' -import type { HOC } from 'recompose' +import type { HOC } from '../..' type EnhancedCompProps = { eA: 1 } diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_onlyUpdateForPropTypes.js b/src/packages/recompose/__tests__/types/test_onlyUpdateForPropTypes.js similarity index 85% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_onlyUpdateForPropTypes.js rename to src/packages/recompose/__tests__/types/test_onlyUpdateForPropTypes.js index 2a0ea1e8..0ad7b21d 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_onlyUpdateForPropTypes.js +++ b/src/packages/recompose/__tests__/types/test_onlyUpdateForPropTypes.js @@ -1,9 +1,9 @@ /* eslint-disable no-unused-vars, no-unused-expressions */ /* @flow */ import React from 'react' -import { compose, withProps, onlyUpdateForPropTypes } from 'recompose' +import { compose, withProps, onlyUpdateForPropTypes } from '../..' -import type { HOC } from 'recompose' +import type { HOC } from '../..' type EnhancedCompProps = { eA: 1 } diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_pure.js b/src/packages/recompose/__tests__/types/test_pure.js similarity index 87% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_pure.js rename to src/packages/recompose/__tests__/types/test_pure.js index 1f59737f..fe65e7e5 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_pure.js +++ b/src/packages/recompose/__tests__/types/test_pure.js @@ -1,9 +1,9 @@ /* eslint-disable no-unused-vars, no-unused-expressions */ /* @flow */ import React from 'react' -import { compose, withProps, pure } from 'recompose' +import { compose, withProps, pure } from '../..' -import type { HOC } from 'recompose' +import type { HOC } from '../..' type EnhancedCompProps = { eA: 1 } diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_shouldUpdate.js b/src/packages/recompose/__tests__/types/test_shouldUpdate.js similarity index 90% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_shouldUpdate.js rename to src/packages/recompose/__tests__/types/test_shouldUpdate.js index 921f639d..edd013b7 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_shouldUpdate.js +++ b/src/packages/recompose/__tests__/types/test_shouldUpdate.js @@ -1,9 +1,9 @@ /* eslint-disable no-unused-vars, no-unused-expressions, arrow-body-style */ /* @flow */ import React from 'react' -import { compose, withProps, shouldUpdate } from 'recompose' +import { compose, withProps, shouldUpdate } from '../..' -import type { HOC } from 'recompose' +import type { HOC } from '../..' type EnhancedCompProps = { eA: 1 } diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_statics.js b/src/packages/recompose/__tests__/types/test_statics.js similarity index 94% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_statics.js rename to src/packages/recompose/__tests__/types/test_statics.js index c758f4f1..546fa9b6 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_statics.js +++ b/src/packages/recompose/__tests__/types/test_statics.js @@ -7,9 +7,9 @@ import { setStatic, setPropTypes, setDisplayName, -} from 'recompose' +} from '../..' // import PropTypes from 'prop-types' -import type { HOC } from 'recompose' +import type { HOC } from '../..' const PropTypes = { string: () => {}, diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_toClass.js b/src/packages/recompose/__tests__/types/test_toClass.js similarity index 86% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_toClass.js rename to src/packages/recompose/__tests__/types/test_toClass.js index 545d6e63..6ccf4944 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_toClass.js +++ b/src/packages/recompose/__tests__/types/test_toClass.js @@ -1,9 +1,9 @@ /* eslint-disable no-unused-vars, no-unused-expressions */ /* @flow */ import React from 'react' -import { compose, withProps, toClass } from 'recompose' +import { compose, withProps, toClass } from '../..' -import type { HOC } from 'recompose' +import type { HOC } from '../..' type EnhancedCompProps = { eA: 1 } diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_utils.js b/src/packages/recompose/__tests__/types/test_utils.js similarity index 85% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_utils.js rename to src/packages/recompose/__tests__/types/test_utils.js index 55e19bcc..362ddbc0 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_utils.js +++ b/src/packages/recompose/__tests__/types/test_utils.js @@ -2,9 +2,9 @@ /* @flow */ import React from 'react' -import { compose, withProps, hoistStatics } from 'recompose' +import { compose, withProps, hoistStatics } from '../..' -import type { HOC } from 'recompose' +import type { HOC } from '../..' type EnhancedCompProps = { a: number } diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_voodoo.js b/src/packages/recompose/__tests__/types/test_voodoo.js similarity index 98% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_voodoo.js rename to src/packages/recompose/__tests__/types/test_voodoo.js index 4c2442e1..840370b0 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_voodoo.js +++ b/src/packages/recompose/__tests__/types/test_voodoo.js @@ -9,9 +9,9 @@ import { renameProp, renameProps, withState, -} from 'recompose' +} from '../..' -import type { HOC } from 'recompose' +import type { HOC } from '../..' type EnhancedCompProps = { eA: number, diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_withContext.js b/src/packages/recompose/__tests__/types/test_withContext.js similarity index 88% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_withContext.js rename to src/packages/recompose/__tests__/types/test_withContext.js index 8bc52483..e79d7ad9 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_withContext.js +++ b/src/packages/recompose/__tests__/types/test_withContext.js @@ -1,9 +1,9 @@ /* eslint-disable no-unused-vars, no-unused-expressions, arrow-body-style */ /* @flow */ import React from 'react' -import { compose, withProps, withContext } from 'recompose' +import { compose, withProps, withContext } from '../..' -import type { HOC } from 'recompose' +import type { HOC } from '../..' type EnhancedCompProps = { eA: 1 } diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_withHandlers.js b/src/packages/recompose/__tests__/types/test_withHandlers.js similarity index 84% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_withHandlers.js rename to src/packages/recompose/__tests__/types/test_withHandlers.js index f871c891..798c48df 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_withHandlers.js +++ b/src/packages/recompose/__tests__/types/test_withHandlers.js @@ -2,13 +2,14 @@ /* @flow */ import React from 'react' -import { compose, withProps, withHandlers } from 'recompose' +import { compose, withProps, withHandlers } from '../..' -import type { HOC } from 'recompose' +import type { HOC } from '../..' type EnhancedCompProps = { value: number, onChange: (value: number) => void, + onOtherChange: (value: { id: string }) => void, } const enhancer: HOC<*, EnhancedCompProps> = compose( @@ -17,11 +18,16 @@ const enhancer: HOC<*, EnhancedCompProps> = compose( props.onChange(value) return true }, + onOtherValueChange: props => value => { + props.onOtherChange(value) + return true + }, }), // here props itself will not be infered without explicit handler args types withProps(props => ({ valueClone: (props.value: number), resType: (props.onValueChange(0): boolean), + ee: props.onOtherValueChange({ id: 'aa' }), // $ExpectError result is not any or number resTypeErr: (props.onValueChange(0): number), diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_withProps.js b/src/packages/recompose/__tests__/types/test_withProps.js similarity index 93% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_withProps.js rename to src/packages/recompose/__tests__/types/test_withProps.js index 52362a1a..9503044f 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_withProps.js +++ b/src/packages/recompose/__tests__/types/test_withProps.js @@ -1,9 +1,9 @@ /* eslint-disable no-unused-vars, no-unused-expressions */ /* @flow */ import React from 'react' -import { compose, withProps } from 'recompose' +import { compose, withProps } from '../..' -import type { HOC } from 'recompose' +import type { HOC } from '../..' type EnhancedCompProps = { a: string, b: number } diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_withPropsOnChange.js b/src/packages/recompose/__tests__/types/test_withPropsOnChange.js similarity index 95% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_withPropsOnChange.js rename to src/packages/recompose/__tests__/types/test_withPropsOnChange.js index fef5ec92..fea890f8 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_withPropsOnChange.js +++ b/src/packages/recompose/__tests__/types/test_withPropsOnChange.js @@ -1,9 +1,9 @@ /* eslint-disable no-unused-vars, no-unused-expressions, arrow-body-style */ /* @flow */ import React from 'react' -import { compose, withProps, withPropsOnChange } from 'recompose' +import { compose, withProps, withPropsOnChange } from '../..' -import type { HOC } from 'recompose' +import type { HOC } from '../..' type EnhancedCompProps = { eA: 1 } diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_withStateHandlers.js b/src/packages/recompose/__tests__/types/test_withStateHandlers.js similarity index 91% rename from types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_withStateHandlers.js rename to src/packages/recompose/__tests__/types/test_withStateHandlers.js index 9d436ae8..ff6cb61e 100644 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/test_withStateHandlers.js +++ b/src/packages/recompose/__tests__/types/test_withStateHandlers.js @@ -2,9 +2,9 @@ /* @flow */ import React from 'react' -import { compose, withProps, withStateHandlers } from 'recompose' +import { compose, withProps, withStateHandlers } from '../..' -import type { HOC } from 'recompose' +import type { HOC } from '../..' type EnhancedCompProps = { initialCounter: number, @@ -12,7 +12,7 @@ type EnhancedCompProps = { const enhancer: HOC<*, EnhancedCompProps> = compose( withStateHandlers( - { value: 'world', letIt: 'be', obj: ({}: { [key: string]: string }) }, + { value: 'Hello', letIt: 'be', obj: ({}: { [key: string]: string }) }, { // we need to set argument type so inference will work good setValue: (state, props) => (value: string) => ({ @@ -66,12 +66,13 @@ const enhancerFuncInit: HOC<*, EnhancedCompProps> = compose( })) ) -const BaseComponent = ({ hi, changeValue }) => +const BaseComponent = ({ hi, changeValue, setValue }) =>
{ // check that supports few arguments const x = changeValue({ i: 1, j: '1' }, 1) + setValue('ww') // Check that result is void ;(x: void) diff --git a/src/packages/recompose/index.js.flow b/src/packages/recompose/index.js.flow new file mode 100644 index 00000000..077cb729 --- /dev/null +++ b/src/packages/recompose/index.js.flow @@ -0,0 +1,262 @@ +/* eslint-disable */ +/* @flow */ + +/** + * 1) Types give additional constraint on a language, recompose was written on the untyped language + * as a consequence of this fact + * for some recompose HOCs is near impossible to add correct typings. + * 2) flow sometimes does not work as expected. + * + * So any help and suggestions will be very appreciated. + * + * ----------------------------------------------------------------------------------- + * Type definition of recompose HOCs are splitted into 2 parts, + * "HOCs with good flow support" - in most cases you can use them without big issues, + * see `test_${hocName}.js` for the idea. + * Some known issues: + * see test_mapProps.js - inference work but type errors are not detected in hocs + * + * SUPPORTED HOCs: + * defaultProps, mapProps, withProps, withStateHandlers, withHandlers, pure, + * onlyUpdateForKeys, shouldUpdate, renderNothing, renderComponent, branch, withPropsOnChange, + * onlyUpdateForPropTypes, toClass, withContext, getContext, + * setStatic, setPropTypes, setDisplayName, + * ----------------------------------------------------------------------------------- + * "TODO (UNSUPPORTED) HOCs" - you need to provide type information + * (no automatic type inference), voodoo dancing etc + * see `test_voodoo.js` for the idea + * + * remember that: + * flattenProp,renameProp, renameProps can easily be replaced with withProps + * withReducer, withState -> use withStateHandlers instead + * lifecycle -> you don't need recompose if you need a lifecycle, just use React class instead + * mapPropsStream -> see test_mapPropsStream.js + * ----------------------------------------------------------------------------------- + * + * utils: + * getDisplayName, wrapDisplayName, shallowEqual, + * isClassComponent, createSink, componentFromProp, + * nest, hoistStatics, + */ + +//------------------- + +// ----------------------------------------------------------------- +// Private declarations +// ----------------------------------------------------------------- + +declare type ExtractToVoid = ( + v: (a: A, b: B, c: C) => R +) => (A, B, C) => void + +declare type ExtractStateHandlersCodomain = ( + v: (state: State, props: Enhanced) => V +) => V + +declare type ExtractHandlersCodomain = ( + v: (props: Enhanced) => V +) => V + +declare type UnaryFn = (a: A) => R + +// ----------------------------------------------------------------- +// Public declarations +// ----------------------------------------------------------------- + +export type Component = React$ComponentType + +export type HOC = UnaryFn, Component> + +declare export var compose: $Compose + +// --------------------------------------------------------------------------- +// ----------------===<<>>===-------------------- +// --------------------------------------------------------------------------- + +declare export function defaultProps( + defProps: Default +): HOC<{ ...$Exact, ...Default }, Enhanced> + +declare export function mapProps( + propsMapper: (ownerProps: Enhanced) => Base +): HOC + +declare export function withProps( + propsMapper: ((ownerProps: Enhanced) => BaseAdd) | BaseAdd +): HOC<{ ...$Exact, ...BaseAdd }, Enhanced> + +declare export function withStateHandlers< + State, + Enhanced, + StateHandlers: { + [key: string]: ( + state: State, + props: Enhanced + ) => (...payload: any[]) => $Shape, + } +>( + initialState: ((props: Enhanced) => State) | State, + stateUpdaters: StateHandlers +): HOC< + { + ...$Exact, + ...$Exact, + ...$ObjMap< + $ObjMap, + ExtractToVoid + >, + }, + Enhanced +> + +declare export function withHandlers< + Enhanced, + Handlers: + | (( + props: Enhanced + ) => { + [key: string]: (props: Enhanced) => Function, + }) + | { + [key: string]: (props: Enhanced) => Function, + } +>( + handlers: ((props: Enhanced) => Handlers) | Handlers +): HOC< + { + ...$Exact, + ...$ObjMap, + }, + Enhanced +> + +declare export function pure(a: Component): Component +declare export function onlyUpdateForPropTypes(a: Component): Component +declare export function onlyUpdateForKeys(Array<$Keys>): HOC +declare export function shouldUpdate( + (props: A, nextProps: A) => boolean +): HOC + +declare export function toClass(a: Component): Component + +declare export function withContext( + childContextTypes: ContextPropTypes, + getChildContext: (props: A) => ContextObj +): HOC + +declare export function getContext( + contextTypes: CtxTypes +): HOC<{ ...$Exact, ...CtxTypes }, Enhanced> + +/** + * It's wrong declaration but having that renderNothing and renderComponent are somehow useless + * outside branch enhancer, we just give it an id type + * so common way of using branch like + * `branch(testFn, renderNothing | renderComponent(Comp))` will work as expected. + * Tests are placed at test_branch. + */ +declare export function renderNothing(C: Component): Component +declare export function renderComponent(a: Component): HOC + +/** + * We make an assumtion that left and right have the same type if exists + */ +declare export function branch( + testFn: (props: Enhanced) => boolean, + // not a HOC because of inference problems, this works but HOC is not + left: (Component) => Component, + // I never use right part and it can be a problem with inference as should be same type as left + right?: (Component) => Component +): HOC + +// test_statics +declare export function setStatic(key: string, value: any): HOC +declare export function setPropTypes(propTypes: Object): HOC +declare export function setDisplayName(displayName: string): HOC + +declare export function withPropsOnChange( + shouldMapOrKeys: + | ((props: Enhanced, nextProps: Enhanced) => boolean) + | Array<$Keys>, + propsMapper: (ownerProps: Enhanced) => BaseAdd +): HOC<{ ...$Exact, ...BaseAdd }, Enhanced> + +// --------------------------------------------------------------------------- +// ----------------===<<>>===------------------------ +// --------------------------------------------------------------------------- + +// use withProps instead +declare export function flattenProp( + propName: $Keys +): HOC + +// use withProps instead +declare export function renameProp( + oldName: $Keys, + newName: $Keys +): HOC + +// use withProps instead +declare export function renameProps(nameMap: { + [key: $Keys]: $Keys, +}): HOC + +// use withStateHandlers instead +declare export function withState( + stateName: string, + stateUpdaterName: string, + initialState: T | ((props: Enhanced) => T) +): HOC + +// use withStateHandlers instead +declare export function withReducer( + stateName: string, + dispatchName: string, + reducer: (state: State, action: Action) => State, + initialState: State +): HOC + +// lifecycle use React instead +declare export function lifecycle(spec: Object): HOC + +// Help needed, as explicitly providing the type +// errors not detected, see TODO at test_mapPropsStream.js +declare export function mapPropsStream( + (props$: any) => any +): HOC + +// --------------------------------------------------------------------------- +// -----------------------------===<<>>===----------------------------- +// --------------------------------------------------------------------------- + +declare export function getDisplayName(C: Component): string + +declare export function wrapDisplayName( + C: Component, + wrapperName: string +): string + +declare export function shallowEqual(objA: mixed, objB: mixed): boolean + +declare export function isClassComponent(value: any): boolean + +declare export function createSink( + callback: (props: A) => void +): Component + +declare export function componentFromProp(propName: string): Component + +declare export function nest( + ...Components: Array | string> +): Component + +declare export function hoistStatics>(hoc: H): H + +declare export function componentFromStream( + (props$: any) => any +): T => React$Element + +declare export function createEventHandler(): { + stream: any, + handler: Function, +} diff --git a/types/flow-typed/README.md b/types/flow-typed/README.md deleted file mode 100644 index 741b6c2e..00000000 --- a/types/flow-typed/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# flow-typed definitions for recompose - -Up to date definitions for recompose package. -Must be synchronized to [flow-typed](https://github.com/flowtype/flow-typed) - -## Contribute - -```shell -# git clone recompose -cd recompose/examples/flow-typed -yarn -yarn flow -``` diff --git a/types/flow-typed/package.json b/types/flow-typed/package.json deleted file mode 100644 index 5f98549c..00000000 --- a/types/flow-typed/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "recompose-flow-typed", - "version": "1.0.0", - "main": "index.js", - "author": "istarkov@gmail.com", - "license": "MIT", - "devDependencies": { - "flow-bin": "^0.55.0", - "prop-types": "^15.5.10", - "rxjs": "^5.4.2" - }, - "scripts": { - "flow": "flow" - } -} diff --git a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/recompose_v0.24.x.js b/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/recompose_v0.24.x.js deleted file mode 100644 index ebf0910a..00000000 --- a/types/flow-typed/recompose_v0.24.x/flow_v0.55.x-/recompose_v0.24.x.js +++ /dev/null @@ -1,270 +0,0 @@ -/* eslint-disable */ - -/** - * 1) Types give additional constraint on a language, recompose was written on the untyped language - * as a consequence of this fact - * for some recompose HOCs is near impossible to add correct typings. - * 2) flow sometimes does not work as expected. - * - * So any help and suggestions will be very appreciated. - * - * ----------------------------------------------------------------------------------- - * Type definition of recompose HOCs are splitted into 2 parts, - * "HOCs with good flow support" - in most cases you can use them without big issues, - * see `test_${hocName}.js` for the idea. - * Some known issues: - * see test_mapProps.js - inference work but type errors are not detected in hocs - * - * SUPPORTED HOCs: - * defaultProps, mapProps, withProps, withStateHandlers, withHandlers, pure, - * onlyUpdateForKeys, shouldUpdate, renderNothing, renderComponent, branch, withPropsOnChange, - * onlyUpdateForPropTypes, toClass, withContext, getContext, - * setStatic, setPropTypes, setDisplayName, - * ----------------------------------------------------------------------------------- - * "TODO (UNSUPPORTED) HOCs" - you need to provide type information - * (no automatic type inference), voodoo dancing etc - * see `test_voodoo.js` for the idea - * - * remember that: - * flattenProp,renameProp, renameProps can easily be replaced with withProps - * withReducer, withState -> use withStateHandlers instead - * lifecycle -> you don't need recompose if you need a lifecycle, just use React class instead - * mapPropsStream -> see test_mapPropsStream.js - * ----------------------------------------------------------------------------------- - * - * utils: - * getDisplayName, wrapDisplayName, shallowEqual, - * isClassComponent, createSink, componentFromProp, - * nest, hoistStatics, - */ - -//------------------- - -declare module 'recompose' { - // ----------------------------------------------------------------- - // Private declarations - // ----------------------------------------------------------------- - - declare type Void_ R> = ( - A, - B, - C, - D - ) => void - - declare type Void = Void_<*, *, *, *, *, T> - - declare type ExtractStateHandlersCodomain = ( - v: (state: State, props: Enhanced) => V - ) => Void - - declare type ExtractHandlersCodomain = ( - v: (props: Enhanced) => V - ) => V - - declare type UnaryFn = (a: A) => R - - // ----------------------------------------------------------------- - // Public declarations - // ----------------------------------------------------------------- - - declare export type Component = React$ComponentType - - declare export type HOC = UnaryFn< - Component, - Component - > - - declare export var compose: $Compose - - // --------------------------------------------------------------------------- - // ----------------===<<>>===-------------------- - // --------------------------------------------------------------------------- - - declare export function defaultProps( - defProps: Default - ): HOC<{ ...$Exact, ...Default }, Enhanced> - - declare export function mapProps( - propsMapper: (ownerProps: Enhanced) => Base - ): HOC - - declare export function withProps( - propsMapper: ((ownerProps: Enhanced) => BaseAdd) | BaseAdd - ): HOC<{ ...$Exact, ...BaseAdd }, Enhanced> - - declare export function withStateHandlers< - State, - Enhanced, - StateHandlers: { - [key: string]: ( - state: State, - props: Enhanced - ) => (...payload: any[]) => $Shape, - } - >( - initialState: ((props: Enhanced) => State) | State, - stateUpdaters: StateHandlers - ): HOC< - { - ...$Exact, - ...$Exact, - ...$ObjMap, - }, - Enhanced - > - - declare export function withHandlers< - Enhanced, - Handlers: - | (( - props: Enhanced - ) => { - [key: string]: (props: Enhanced) => Function, - }) - | { - [key: string]: (props: Enhanced) => Function, - } - >( - handlers: ((props: Enhanced) => Handlers) | Handlers - ): HOC< - { - ...$Exact, - ...$ObjMap, - }, - Enhanced - > - - declare export function pure(a: Component): Component - declare export function onlyUpdateForPropTypes( - a: Component - ): Component - declare export function onlyUpdateForKeys(Array<$Keys>): HOC - declare export function shouldUpdate( - (props: A, nextProps: A) => boolean - ): HOC - - declare export function toClass(a: Component): Component - - declare export function withContext( - childContextTypes: ContextPropTypes, - getChildContext: (props: A) => ContextObj - ): HOC - - declare export function getContext( - contextTypes: CtxTypes - ): HOC<{ ...$Exact, ...CtxTypes }, Enhanced> - - /** - * It's wrong declaration but having that renderNothing and renderComponent are somehow useless - * outside branch enhancer, we just give it an id type - * so common way of using branch like - * `branch(testFn, renderNothing | renderComponent(Comp))` will work as expected. - * Tests are placed at test_branch. - */ - declare export function renderNothing(C: Component): Component - declare export function renderComponent(a: Component): HOC - - /** - * We make an assumtion that left and right have the same type if exists - */ - declare export function branch( - testFn: (props: Enhanced) => boolean, - // not a HOC because of inference problems, this works but HOC is not - left: (Component) => Component, - // I never use right part and it can be a problem with inference as should be same type as left - right?: (Component) => Component - ): HOC - - // test_statics - declare export function setStatic(key: string, value: any): HOC - declare export function setPropTypes(propTypes: Object): HOC - declare export function setDisplayName(displayName: string): HOC - - declare export function withPropsOnChange( - shouldMapOrKeys: - | ((props: Enhanced, nextProps: Enhanced) => boolean) - | Array<$Keys>, - propsMapper: (ownerProps: Enhanced) => BaseAdd - ): HOC<{ ...$Exact, ...BaseAdd }, Enhanced> - - // --------------------------------------------------------------------------- - // ----------------===<<>>===------------------------ - // --------------------------------------------------------------------------- - - // use withProps instead - declare export function flattenProp( - propName: $Keys - ): HOC - - // use withProps instead - declare export function renameProp( - oldName: $Keys, - newName: $Keys - ): HOC - - // use withProps instead - declare export function renameProps(nameMap: { - [key: $Keys]: $Keys, - }): HOC - - // use withStateHandlers instead - declare export function withState( - stateName: string, - stateUpdaterName: string, - initialState: T | ((props: Enhanced) => T) - ): HOC - - // use withStateHandlers instead - declare export function withReducer( - stateName: string, - dispatchName: string, - reducer: (state: State, action: Action) => State, - initialState: State - ): HOC - - // lifecycle use React instead - declare export function lifecycle(spec: Object): HOC - - // Help needed, as explicitly providing the type - // errors not detected, see TODO at test_mapPropsStream.js - declare export function mapPropsStream( - (props$: any) => any - ): HOC - - // --------------------------------------------------------------------------- - // -----------------------------===<<>>===----------------------------- - // --------------------------------------------------------------------------- - - declare export function getDisplayName(C: Component): string - - declare export function wrapDisplayName( - C: Component, - wrapperName: string - ): string - - declare export function shallowEqual(objA: mixed, objB: mixed): boolean - - declare export function isClassComponent(value: any): boolean - - declare export function createSink( - callback: (props: A) => void - ): Component - - declare export function componentFromProp(propName: string): Component - - declare export function nest( - ...Components: Array | string> - ): Component - - declare export function hoistStatics>(hoc: H): H - - declare export function componentFromStream( - (props$: any) => any - ): T => React$Element - - declare export function createEventHandler(): { - stream: any, - handler: Function, - } -} diff --git a/types/flow-typed/yarn.lock b/types/flow-typed/yarn.lock deleted file mode 100644 index bc4777db..00000000 --- a/types/flow-typed/yarn.lock +++ /dev/null @@ -1,104 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -asap@~2.0.3: - version "2.0.5" - resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.5.tgz#522765b50c3510490e52d7dcfe085ef9ba96958f" - -core-js@^1.0.0: - version "1.2.7" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" - -encoding@^0.1.11: - version "0.1.12" - resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb" - dependencies: - iconv-lite "~0.4.13" - -fbjs@^0.8.9: - version "0.8.12" - resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.12.tgz#10b5d92f76d45575fd63a217d4ea02bea2f8ed04" - dependencies: - core-js "^1.0.0" - isomorphic-fetch "^2.1.1" - loose-envify "^1.0.0" - object-assign "^4.1.0" - promise "^7.1.1" - setimmediate "^1.0.5" - ua-parser-js "^0.7.9" - -flow-bin@^0.55.0: - version "0.55.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.55.0.tgz#9083da9327bd8cab6b4076d63d85f2247a7eae1b" - -iconv-lite@~0.4.13: - version "0.4.18" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.18.tgz#23d8656b16aae6742ac29732ea8f0336a4789cf2" - -is-stream@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - -isomorphic-fetch@^2.1.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9" - dependencies: - node-fetch "^1.0.1" - whatwg-fetch ">=0.10.0" - -js-tokens@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" - -loose-envify@^1.0.0, loose-envify@^1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848" - dependencies: - js-tokens "^3.0.0" - -node-fetch@^1.0.1: - version "1.7.1" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.1.tgz#899cb3d0a3c92f952c47f1b876f4c8aeabd400d5" - dependencies: - encoding "^0.1.11" - is-stream "^1.0.1" - -object-assign@^4.1.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - -promise@^7.1.1: - version "7.3.1" - resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf" - dependencies: - asap "~2.0.3" - -prop-types@^15.5.10: - version "15.5.10" - resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154" - dependencies: - fbjs "^0.8.9" - loose-envify "^1.3.1" - -rxjs@^5.4.2: - version "5.4.2" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.4.2.tgz#2a3236fcbf03df57bae06fd6972fd99e5c08fcf7" - dependencies: - symbol-observable "^1.0.1" - -setimmediate@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" - -symbol-observable@^1.0.1: - version "1.0.4" - resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d" - -ua-parser-js@^0.7.9: - version "0.7.13" - resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.13.tgz#cd9dd2f86493b3f44dbeeef3780fda74c5ee14be" - -whatwg-fetch@>=0.10.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84" diff --git a/yarn.lock b/yarn.lock index d7fd93ce..88403c55 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2632,6 +2632,10 @@ flat-cache@^1.2.1: graceful-fs "^4.1.2" write "^0.2.1" +flow-bin@^0.70.0: + version "0.70.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.70.0.tgz#080ae83a997f2b4ddb3dc2649bf13336825292b5" + flush-write-stream@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.0.3.tgz#c5d586ef38af6097650b49bc41b55fabb19f35bd"