From b5c6598851526b184548eab9b6fe3fb6ebd36192 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Thu, 29 Nov 2018 10:28:39 -0800 Subject: [PATCH] [PR] Add React.Suspense component, remove React.useMutationEffect hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Resolves #7219 - [x] 2fdcda5: Removed `React.useMutationEffect` hook (facebook/react/pull/14336) and updated tests. This hook was only ever exposed in an alpha release of 16.7 and so it should be safe to remove in a non-backwards-compatible way. - [x] dabf49e: Add `React.Suspense` component and tests. (No final public documentation exists for `Suspense` yet– although we're working on it. For the time being, [tests like this](https://github.com/facebook/react/blob/master/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js) can serve as a reference.) - [x] 8df05bd: Fixed invalid `useCallback` definition and tests. - [x] 063b022: Fixed invalid `React.lazy` signature to reflect that a `Promise` with a "default" property should be returned (rather than a React component). Pull Request resolved: https://github.com/facebook/flow/pull/7213 Reviewed By: jbrown215 Differential Revision: D13222880 Pulled By: bvaughn fbshipit-source-id: 77e59e320698567c343c91a67b3aa91e9c925873 --- lib/react.js | 19 +- .../getters_and_setters.exp | 8 +- tests/new_react/new_react.exp | 46 +- tests/react/react.exp | 795 +++++++++++++----- tests/react/useCallback_hook.js | 19 +- tests/react_16_6/Suspense.js | 49 ++ tests/react_16_6/lazy.js | 13 +- tests/react_16_6/react_16_6.exp | 168 +++- tests/react_children/react_children.exp | 12 +- tests/react_imports/react_imports.exp | 194 ++--- tests/react_jsx/react_jsx.exp | 28 +- tests/type-at-pos_react/type-at-pos_react.exp | 2 +- 12 files changed, 979 insertions(+), 374 deletions(-) create mode 100644 tests/react_16_6/Suspense.js diff --git a/lib/react.js b/lib/react.js index eecdf1338da..95934ff5f56 100644 --- a/lib/react.js +++ b/lib/react.js @@ -258,6 +258,12 @@ declare module react { declare export var ConcurrentMode: ({children: ?React$Node}) => React$Node; // 16.7+ declare export var StrictMode: ({children: ?React$Node}) => React$Node; + declare export var Suspense: React$ComponentType<{ + children?: ?React$Node, + fallback?: React$Node, + maxDuration?: number + }>; // 16.6+ + declare export type ElementProps = React$ElementProps; declare export type ElementConfig = React$ElementConfig; declare export type ElementRef = React$ElementRef; @@ -285,7 +291,7 @@ declare module react { ): React$StatelessFunctionalComponent

; declare export function lazy

( - component: () => React$ComponentType

, + component: () => Promise<{ default: React$ComponentType

}>, ): React$ComponentType

; declare type MaybeCleanUpFn = ?(() => mixed); @@ -312,18 +318,13 @@ declare module react { inputs: ?$ReadOnlyArray, ): void; - declare export function useMutationEffect( - create: () => MaybeCleanUpFn, - inputs: ?$ReadOnlyArray, - ): void; - declare export function useLayoutEffect( create: () => MaybeCleanUpFn, inputs: ?$ReadOnlyArray, ): void; - declare export function useCallback( - callback: () => T | void, + declare export function useCallback) => mixed>( + callback: T, inputs: ?$ReadOnlyArray, ): T; @@ -358,12 +359,12 @@ declare module react { +Children: typeof Children, +ConcurrentMode: typeof ConcurrentMode, +StrictMode: typeof StrictMode, + +Suspense: typeof Suspense, +useContext: typeof useContext, +useState: typeof useState, +useReducer: typeof useReducer, +useRef: typeof useRef, +useEffect: typeof useEffect, - +useMutationEffect: typeof useMutationEffect, +useLayoutEffect: typeof useLayoutEffect, +useCallback: typeof useCallback, +useMemo: typeof useMemo, diff --git a/tests/getters_and_setters/getters_and_setters.exp b/tests/getters_and_setters/getters_and_setters.exp index 45e716dc254..ad7c57bbb13 100644 --- a/tests/getters_and_setters/getters_and_setters.exp +++ b/tests/getters_and_setters/getters_and_setters.exp @@ -465,8 +465,8 @@ References: react.js:17:13 17| (); // error: number ~> string ^^^^^ [1] - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [2] @@ -482,8 +482,8 @@ References: react.js:18:20 18| (); // error: number ~> string ^ [1] - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [2] diff --git a/tests/new_react/new_react.exp b/tests/new_react/new_react.exp index 4dcc142ff4c..f36e2f37ab5 100644 --- a/tests/new_react/new_react.exp +++ b/tests/new_react/new_react.exp @@ -189,8 +189,8 @@ Cannot assign `this.props.x` to `_` because number [1] is incompatible with stri ^^^^^^^^^^^^ References: - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [1] classes.js:57:12 57| var _: string = this.props.x; @@ -388,8 +388,8 @@ Cannot assign `this.props.z` to `qux` because: ^^^^^^^^^^^^ References: - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [1] new_react.js:19:18 19| var qux: string = this.props.z; @@ -405,8 +405,8 @@ Cannot assign `this.props.x` to `w` because string [1] is incompatible with numb ^^^^^^^^^^^^ References: - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [1] new_react.js:20:15 20| var w:number = this.props.x; @@ -439,8 +439,8 @@ References: new_react.js:29:23 29| var element = ; ^ [1] - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [2] @@ -545,8 +545,8 @@ Cannot assign `this.props.x` to `a` because: ^^^^^^^^^^^^ References: - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [1] props.js:14:16 14| var a: number = this.props.x; // error @@ -582,8 +582,8 @@ Cannot assign `this.props.z` to `c` because: ^^^^^^^^^^^^ References: - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [1] props.js:16:16 16| var c: string = this.props.z; // error @@ -604,14 +604,14 @@ References: props.js:20:29 20| var element = ; // 3 errors ^^^^^ [1] - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [2] props.js:20:49 20| var element = ; // 3 errors ^^^^^ [3] - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [4] @@ -668,8 +668,8 @@ References: props2.js:9:41 9| getInitialState: function(): { bar: number } { ^^^^^^ [1] - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [2] props2.js:15:42 15| return ; @@ -700,12 +700,12 @@ Cannot get `React.PropTypes.string.inRequired` because property `inRequired` is ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ References: - /react.js:386:39 + /react.js:387:39 v - 386| type ReactPropsChainableTypeChecker = { - 387| isRequired: ReactPropsCheckType; - 388| (props: any, propName: string, componentName: string, href?: string): ?Error; - 389| }; + 387| type ReactPropsChainableTypeChecker = { + 388| isRequired: ReactPropsCheckType; + 389| (props: any, propName: string, componentName: string, href?: string): ?Error; + 390| }; ^ [1] diff --git a/tests/react/react.exp b/tests/react/react.exp index d6bb821ae99..c1c56b65db8 100644 --- a/tests/react/react.exp +++ b/tests/react/react.exp @@ -80,8 +80,8 @@ Cannot cast `this.props.foo` to empty because string [1] is incompatible with em ^^^^^^^^^^^^^^ References: - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [1] create_class.js:7:22 7| (this.props.foo: empty); // error: string ~> empty @@ -97,8 +97,8 @@ Cannot cast `this.props.bar` to empty because number [1] is incompatible with em ^^^^^^^^^^^^^^ References: - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [1] create_class.js:8:22 8| (this.props.bar: empty); // error: number ~> empty @@ -251,8 +251,8 @@ Cannot cast `this.props.foo` to empty because string [1] is incompatible with em ^^^^^^^^^^^^^^ References: - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [1] create_class.js:117:22 117| (this.props.foo: empty); // string ~> empty @@ -268,8 +268,8 @@ Cannot cast `this.state.foo` to empty because string [1] is incompatible with em ^^^^^^^^^^^^^^ References: - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [1] create_class.js:118:22 118| (this.state.foo: empty); // string ~> empty @@ -285,8 +285,8 @@ Cannot cast `this.props.foo` to empty because string [1] is incompatible with em ^^^^^^^^^^^^^^ References: - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [1] create_class.js:133:22 133| (this.props.foo: empty); // string ~> empty @@ -302,8 +302,8 @@ Cannot cast `this.props.foo` to empty because string [1] is incompatible with em ^^^^^^^^^^^^^^ References: - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [1] create_class.js:137:22 137| (this.props.foo: empty); // string ~> empty @@ -319,8 +319,8 @@ Cannot cast `this.props.foo` to empty because string [1] is incompatible with em ^^^^^^^^^^^^^^ References: - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [1] create_class.js:141:22 141| (this.props.foo: empty); // string ~> empty @@ -336,8 +336,8 @@ Cannot cast `nextProps.foo` to empty because string [1] is incompatible with emp ^^^^^^^^^^^^^ References: - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [1] create_class.js:142:21 142| (nextProps.foo: empty); // string ~> empty @@ -353,8 +353,8 @@ Cannot cast `this.props.foo` to empty because string [1] is incompatible with em ^^^^^^^^^^^^^^ References: - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [1] create_class.js:146:22 146| (this.props.foo: empty); // string ~> empty @@ -387,8 +387,8 @@ Cannot cast `nextProps.foo` to empty because string [1] is incompatible with emp ^^^^^^^^^^^^^ References: - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [1] create_class.js:148:21 148| (nextProps.foo: empty); // string ~> empty @@ -435,8 +435,8 @@ Cannot cast `this.props.foo` to empty because string [1] is incompatible with em ^^^^^^^^^^^^^^ References: - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [1] create_class.js:153:22 153| (this.props.foo: empty); // string ~> empty @@ -469,8 +469,8 @@ Cannot cast `nextProps.foo` to empty because string [1] is incompatible with emp ^^^^^^^^^^^^^ References: - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [1] create_class.js:155:21 155| (nextProps.foo: empty); // string ~> empty @@ -503,8 +503,8 @@ Cannot cast `this.props.foo` to empty because string [1] is incompatible with em ^^^^^^^^^^^^^^ References: - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [1] create_class.js:160:22 160| (this.props.foo: empty); // string ~> empty @@ -537,8 +537,8 @@ Cannot cast `nextProps.foo` to empty because string [1] is incompatible with emp ^^^^^^^^^^^^^ References: - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [1] create_class.js:162:21 162| (nextProps.foo: empty); // string ~> empty @@ -571,8 +571,8 @@ Cannot cast `this.props.foo` to empty because string [1] is incompatible with em ^^^^^^^^^^^^^^ References: - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [1] create_class.js:167:22 167| (this.props.foo: empty); // string ~> empty @@ -1904,8 +1904,8 @@ References: jsx_spread.js:10:19 10| var props = {bar: 42}; ^^ [1] - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [2] @@ -2018,8 +2018,8 @@ References: proptype_arrayOf.js:15:45 15| var fail_mistyped_elems = ^^^^^ [1] - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [2] @@ -2035,8 +2035,8 @@ References: proptype_arrayOf.js:20:36 20| var todo_required = ^^^^ [1] - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [2] @@ -2053,8 +2053,8 @@ References: proptype_arrayOf.js:30:25 30| (); // error: string ~> number ^^ [1] - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [2] @@ -2092,8 +2092,8 @@ Cannot cast `propName` to empty because string [1] is incompatible with empty [2 ^^^^^^^^ References: - /react.js:382:13 - 382| propName: string, + /react.js:383:13 + 383| propName: string, ^^^^^^ [1] proptype_custom_validator.js:8:18 8| (propName: empty); // error: propName is a string @@ -2109,8 +2109,8 @@ Cannot cast `componentName` to empty because string [1] is incompatible with emp ^^^^^^^^^^^^^ References: - /react.js:383:18 - 383| componentName: string, + /react.js:384:18 + 384| componentName: string, ^^^^^^ [1] proptype_custom_validator.js:9:23 9| (componentName: empty); // error: componentName is a string @@ -2128,8 +2128,8 @@ Cannot cast `href` to empty because: ^^^^ References: - /react.js:384:10 - 384| href?: string) => ?Error; + /react.js:385:10 + 385| href?: string) => ?Error; ^^^^^^ [1] proptype_custom_validator.js:10:14 10| (href: empty); // error: href is an optional string @@ -2148,8 +2148,8 @@ References: proptype_custom_validator.js:11:18 11| return (0: mixed); // error: should return ?Error ^^^^^ [1] - /react.js:384:22 - 384| href?: string) => ?Error; + /react.js:385:22 + 385| href?: string) => ?Error; ^^^^^ [2] @@ -2242,8 +2242,8 @@ References: proptype_objectOf.js:15:47 15| var fail_mistyped_props = ^^^^^ [1] - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [2] @@ -2259,8 +2259,8 @@ References: proptype_objectOf.js:20:38 20| var todo_required = ^^^^ [1] - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [2] @@ -2276,8 +2276,8 @@ References: proptype_objectOf.js:30:27 30| (); // error: string ~> number ^^ [1] - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [2] @@ -2452,11 +2452,11 @@ References: proptype_oneOfType.js:24:32 24| var fail_bool = ; ^^^^ [1] - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [2] - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [3] @@ -2474,11 +2474,11 @@ References: proptype_oneOfType.js:29:36 29| var todo_required = ; ^^^^ [1] - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [2] - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [3] @@ -2494,8 +2494,8 @@ References: proptype_oneOfType.js:41:22 41| (); // error: number ~> string ^ [1] - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [2] @@ -2577,14 +2577,14 @@ Cannot cast `React.PropTypes.arrayOf` to `NoFun` because: ^^^^^^^^^^^^^^^^^^^^^^^ References: - /react.js:392:17 - 392| (typeChecker: ReactPropsCheckType) => ReactPropsChainableTypeChecker; + /react.js:393:17 + 393| (typeChecker: ReactPropsCheckType) => ReactPropsChainableTypeChecker; ^^^^^^^^^^^^^^^^^^^ [1] proptypes_builtins.js:3:14 3| type NoFun = mixed => empty; ^^^^^ [2] - /react.js:392:41 - 392| (typeChecker: ReactPropsCheckType) => ReactPropsChainableTypeChecker; + /react.js:393:41 + 393| (typeChecker: ReactPropsCheckType) => ReactPropsChainableTypeChecker; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [3] proptypes_builtins.js:3:23 3| type NoFun = mixed => empty; @@ -2601,8 +2601,8 @@ empty [2] in the return value. ^^^^^^^^^^^^^^^^^^^^^^^^^^ References: - /react.js:394:27 - 394| (expectedClass: any) => ReactPropsChainableTypeChecker; + /react.js:395:27 + 395| (expectedClass: any) => ReactPropsChainableTypeChecker; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [1] proptypes_builtins.js:3:23 3| type NoFun = mixed => empty; @@ -2620,14 +2620,14 @@ Cannot cast `React.PropTypes.objectOf` to `NoFun` because: ^^^^^^^^^^^^^^^^^^^^^^^^ References: - /react.js:396:17 - 396| (typeChecker: ReactPropsCheckType) => ReactPropsChainableTypeChecker; + /react.js:397:17 + 397| (typeChecker: ReactPropsCheckType) => ReactPropsChainableTypeChecker; ^^^^^^^^^^^^^^^^^^^ [1] proptypes_builtins.js:3:14 3| type NoFun = mixed => empty; ^^^^^ [2] - /react.js:396:41 - 396| (typeChecker: ReactPropsCheckType) => ReactPropsChainableTypeChecker; + /react.js:397:41 + 397| (typeChecker: ReactPropsCheckType) => ReactPropsChainableTypeChecker; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [3] proptypes_builtins.js:3:23 3| type NoFun = mixed => empty; @@ -2645,14 +2645,14 @@ Cannot cast `React.PropTypes.oneOf` to `NoFun` because: ^^^^^^^^^^^^^^^^^^^^^ References: - /react.js:398:20 - 398| (expectedValues: Array) => ReactPropsChainableTypeChecker; + /react.js:399:20 + 399| (expectedValues: Array) => ReactPropsChainableTypeChecker; ^^^^^^^^^^ [1] proptypes_builtins.js:3:14 3| type NoFun = mixed => empty; ^^^^^ [2] - /react.js:398:35 - 398| (expectedValues: Array) => ReactPropsChainableTypeChecker; + /react.js:399:35 + 399| (expectedValues: Array) => ReactPropsChainableTypeChecker; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [3] proptypes_builtins.js:3:23 3| type NoFun = mixed => empty; @@ -2670,14 +2670,14 @@ Cannot cast `React.PropTypes.oneOfType` to `NoFun` because: ^^^^^^^^^^^^^^^^^^^^^^^^^ References: - /react.js:400:25 - 400| (arrayOfTypeCheckers: Array) => + /react.js:401:25 + 401| (arrayOfTypeCheckers: Array) => ^^^^^^^^^^^^^^^^^^^^^^^^^^ [1] proptypes_builtins.js:3:14 3| type NoFun = mixed => empty; ^^^^^ [2] - /react.js:401:5 - 401| ReactPropsChainableTypeChecker; + /react.js:402:5 + 402| ReactPropsChainableTypeChecker; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [3] proptypes_builtins.js:3:23 3| type NoFun = mixed => empty; @@ -2695,14 +2695,14 @@ Cannot cast `React.PropTypes.shape` to `NoFun` because: ^^^^^^^^^^^^^^^^^^^^^ References: - /react.js:403:16 - 403| (shapeTypes: { [key: string]: ReactPropsCheckType }) => + /react.js:404:16 + 404| (shapeTypes: { [key: string]: ReactPropsCheckType }) => ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [1] proptypes_builtins.js:3:14 3| type NoFun = mixed => empty; ^^^^^ [2] - /react.js:404:5 - 404| ReactPropsChainableTypeChecker; + /react.js:405:5 + 405| ReactPropsChainableTypeChecker; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [3] proptypes_builtins.js:3:23 3| type NoFun = mixed => empty; @@ -3180,63 +3180,121 @@ Cannot call `React.useCallback` because function [1] requires another argument. ^^^^^^^^^^^^^^^^^^^ References: - /react.js:325:38 - v--- - 325| declare export function useCallback( - 326| callback: () => T | void, - 327| inputs: ?$ReadOnlyArray, - 328| ): T; + /react.js:326:38 + v---------------------------------------------- + 326| declare export function useCallback) => mixed>( + 327| callback: T, + 328| inputs: ?$ReadOnlyArray, + 329| ): T; ---^ [1] -Error ---------------------------------------------------------------------------------------- useCallback_hook.js:14:13 +Error ---------------------------------------------------------------------------------------- useCallback_hook.js:12:23 -Cannot assign `React.useCallback(...)` to `numeric` because string [1] is incompatible with number [2]. +Cannot assign `callback()` to `str` because number [1] is incompatible with string [2]. - useCallback_hook.js:14:13 - 14| numeric = React.useCallback(() => 'abc'); // Error: is incompatible with number - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + useCallback_hook.js:12:23 + 12| const str: string = callback();// Error: number is incompatible with string. + ^^^^^^^^^^ References: - useCallback_hook.js:14:37 - 14| numeric = React.useCallback(() => 'abc'); // Error: is incompatible with number - ^^^^^ [1] - useCallback_hook.js:10:16 - 10| let numeric: number; - ^^^^^^ [2] + useCallback_hook.js:10:44 + 10| const callback = React.useCallback(() => 123); + ^^^ [1] + useCallback_hook.js:12:14 + 12| const str: string = callback();// Error: number is incompatible with string. + ^^^^^^ [2] -Error ---------------------------------------------------------------------------------------- useCallback_hook.js:15:42 +Error ----------------------------------------------------------------------------------------- useCallback_hook.js:21:3 -Cannot call `React.useCallback` with object literal bound to `inputs` because object literal [1] is incompatible with -read-only array type [2]. +Cannot call `callback` because function [1] requires another argument. - useCallback_hook.js:15:42 - 15| numeric = React.useCallback(() => 123, {}); // Error: object literal is incompatible with +read-only array type - ^^ [1] + useCallback_hook.js:21:3 + 21| callback(true); // Error: function requires another argument. + ^^^^^^^^^^^^^^ References: - /react.js:327:14 - 327| inputs: ?$ReadOnlyArray, - ^^^^^^^^^^^^^^^^^^^^^ [2] + useCallback_hook.js:16:38 + v------------------------------ + 16| const callback = React.useCallback((num: number, str: string) => { + 17| (num: number); + 18| (str: string); + 19| }); + ^ [1] + + +Error ---------------------------------------------------------------------------------------- useCallback_hook.js:21:12 + +Cannot call `callback` with `true` bound to `num` because boolean [1] is incompatible with number [2]. + + useCallback_hook.js:21:12 + 21| callback(true); // Error: function requires another argument. + ^^^^ [1] + +References: + useCallback_hook.js:16:44 + 16| const callback = React.useCallback((num: number, str: string) => { + ^^^^^^ [2] + + +Error ---------------------------------------------------------------------------------------- useCallback_hook.js:22:12 + +Cannot call `callback` with `'123'` bound to `num` because string [1] is incompatible with number [2]. + + useCallback_hook.js:22:12 + 22| callback('123', 'abc'); // Error: string is incompatible with number. + ^^^^^ [1] + +References: + useCallback_hook.js:16:44 + 16| const callback = React.useCallback((num: number, str: string) => { + ^^^^^^ [2] Error ------------------------------------------------------------------------------------------- useContext_hook.js:6:3 -Cannot call `React.useMutationEffect` because function [1] requires another argument. +Cannot call `React.useMutationEffect` because property `useMutationEffect` is missing in object type [1]. useContext_hook.js:6:3 6| React.useMutationEffect(); // Error: function requires another argument. ^^^^^^^^^^^^^^^^^^^^^^^^^ References: - /react.js:315:44 - v - 315| declare export function useMutationEffect( - 316| create: () => MaybeCleanUpFn, - 317| inputs: ?$ReadOnlyArray, - 318| ): void; - ------^ [1] + /react.js:342:26 + v- + 342| declare export default {| + 343| +DOM: typeof DOM, + 344| +PropTypes: typeof PropTypes, + 345| +version: typeof version, + 346| +checkPropTypes: typeof checkPropTypes, + 347| +memo: typeof memo, + 348| +lazy: typeof lazy, + 349| +createClass: typeof createClass, + 350| +createContext: typeof createContext, + 351| +createElement: typeof createElement, + 352| +cloneElement: typeof cloneElement, + 353| +createFactory: typeof createFactory, + 354| +createRef: typeof createRef, + 355| +isValidElement: typeof isValidElement, + 356| +Component: typeof Component, + : + 358| +Fragment: typeof Fragment, + 359| +Children: typeof Children, + 360| +ConcurrentMode: typeof ConcurrentMode, + 361| +StrictMode: typeof StrictMode, + 362| +Suspense: typeof Suspense, + 363| +useContext: typeof useContext, + 364| +useState: typeof useState, + 365| +useReducer: typeof useReducer, + 366| +useRef: typeof useRef, + 367| +useEffect: typeof useEffect, + 368| +useLayoutEffect: typeof useLayoutEffect, + 369| +useCallback: typeof useCallback, + 370| +useMemo: typeof useMemo, + 371| +useImperativeMethods: typeof useImperativeMethods, + 372| |}; + -^ [1] Error ----------------------------------------------------------------------------------------- useContext_hook.js:21:18 @@ -3320,12 +3378,12 @@ Cannot call `React.useEffect` because function [1] requires another argument. ^^^^^^^^^^^^^^^^^ References: - /react.js:310:36 + /react.js:316:36 v - 310| declare export function useEffect( - 311| create: () => MaybeCleanUpFn, - 312| inputs: ?$ReadOnlyArray, - 313| ): void; + 316| declare export function useEffect( + 317| create: () => MaybeCleanUpFn, + 318| inputs: ?$ReadOnlyArray, + 319| ): void; ------^ [1] @@ -3338,8 +3396,8 @@ Cannot call `React.useEffect` with `1` bound to `create` because number [1] is i ^ [1] References: - /react.js:311:13 - 311| create: () => MaybeCleanUpFn, + /react.js:317:13 + 317| create: () => MaybeCleanUpFn, ^^^^^^^^^^^^^^^^^^^^ [2] @@ -3353,8 +3411,8 @@ type [2]. ^ [1] References: - /react.js:312:14 - 312| inputs: ?$ReadOnlyArray, + /react.js:318:14 + 318| inputs: ?$ReadOnlyArray, ^^^^^^^^^^^^^^^^^^^^^ [2] @@ -3367,13 +3425,13 @@ Cannot call `React.useImperativeMethods` because function [1] requires another a ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ References: - /react.js:335:47 + /react.js:336:47 v--- - 335| declare export function useImperativeMethods( - 336| ref: {current: T | null} | ((inst: T | null) => mixed) | null | void, - 337| create: () => T, - 338| inputs: ?$ReadOnlyArray, - 339| ): void; + 336| declare export function useImperativeMethods( + 337| ref: {current: T | null} | ((inst: T | null) => mixed) | null | void, + 338| create: () => T, + 339| inputs: ?$ReadOnlyArray, + 340| ): void; ------^ [1] @@ -3422,12 +3480,12 @@ Cannot call `React.useLayoutEffect` because function [1] requires another argume ^^^^^^^^^^^^^^^^^^^^^^^ References: - /react.js:320:42 + /react.js:321:42 v - 320| declare export function useLayoutEffect( - 321| create: () => MaybeCleanUpFn, - 322| inputs: ?$ReadOnlyArray, - 323| ): void; + 321| declare export function useLayoutEffect( + 322| create: () => MaybeCleanUpFn, + 323| inputs: ?$ReadOnlyArray, + 324| ): void; ------^ [1] @@ -3441,8 +3499,8 @@ type [2]. ^ [1] References: - /react.js:321:13 - 321| create: () => MaybeCleanUpFn, + /react.js:322:13 + 322| create: () => MaybeCleanUpFn, ^^^^^^^^^^^^^^^^^^^^ [2] @@ -3456,8 +3514,8 @@ type [2]. ^ [1] References: - /react.js:322:14 - 322| inputs: ?$ReadOnlyArray, + /react.js:323:14 + 323| inputs: ?$ReadOnlyArray, ^^^^^^^^^^^^^^^^^^^^^ [2] @@ -3470,12 +3528,12 @@ Cannot call `React.useMemo` because function [1] requires another argument. ^^^^^^^^^^^^^^^ References: - /react.js:330:34 + /react.js:331:34 v--- - 330| declare export function useMemo( - 331| create: () => T, - 332| inputs: ?$ReadOnlyArray, - 333| ): T; + 331| declare export function useMemo( + 332| create: () => T, + 333| inputs: ?$ReadOnlyArray, + 334| ): T; ---^ [1] @@ -3498,50 +3556,407 @@ References: Error ------------------------------------------------------------------------------------ useMutationEffect_hook.js:6:3 -Cannot call `React.useMutationEffect` because function [1] requires another argument. +Cannot call `React.useMutationEffect` because property `useMutationEffect` is missing in object type [1]. useMutationEffect_hook.js:6:3 6| React.useMutationEffect(); // Error: function requires another argument. ^^^^^^^^^^^^^^^^^^^^^^^^^ References: - /react.js:315:44 - v - 315| declare export function useMutationEffect( - 316| create: () => MaybeCleanUpFn, - 317| inputs: ?$ReadOnlyArray, - 318| ): void; - ------^ [1] - - -Error ---------------------------------------------------------------------------------- useMutationEffect_hook.js:22:27 - -Cannot call `React.useMutationEffect` with `1` bound to `create` because number [1] is incompatible with function -type [2]. - - useMutationEffect_hook.js:22:27 + /react.js:342:26 + v- + 342| declare export default {| + 343| +DOM: typeof DOM, + 344| +PropTypes: typeof PropTypes, + 345| +version: typeof version, + 346| +checkPropTypes: typeof checkPropTypes, + 347| +memo: typeof memo, + 348| +lazy: typeof lazy, + 349| +createClass: typeof createClass, + 350| +createContext: typeof createContext, + 351| +createElement: typeof createElement, + 352| +cloneElement: typeof cloneElement, + 353| +createFactory: typeof createFactory, + 354| +createRef: typeof createRef, + 355| +isValidElement: typeof isValidElement, + 356| +Component: typeof Component, + : + 358| +Fragment: typeof Fragment, + 359| +Children: typeof Children, + 360| +ConcurrentMode: typeof ConcurrentMode, + 361| +StrictMode: typeof StrictMode, + 362| +Suspense: typeof Suspense, + 363| +useContext: typeof useContext, + 364| +useState: typeof useState, + 365| +useReducer: typeof useReducer, + 366| +useRef: typeof useRef, + 367| +useEffect: typeof useEffect, + 368| +useLayoutEffect: typeof useLayoutEffect, + 369| +useCallback: typeof useCallback, + 370| +useMemo: typeof useMemo, + 371| +useImperativeMethods: typeof useImperativeMethods, + 372| |}; + -^ [1] + + +Error ----------------------------------------------------------------------------------- useMutationEffect_hook.js:11:3 + +Cannot call `React.useMutationEffect` because property `useMutationEffect` is missing in object type [1]. + + useMutationEffect_hook.js:11:3 + 11| React.useMutationEffect(() => {}); + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +References: + /react.js:342:26 + v- + 342| declare export default {| + 343| +DOM: typeof DOM, + 344| +PropTypes: typeof PropTypes, + 345| +version: typeof version, + 346| +checkPropTypes: typeof checkPropTypes, + 347| +memo: typeof memo, + 348| +lazy: typeof lazy, + 349| +createClass: typeof createClass, + 350| +createContext: typeof createContext, + 351| +createElement: typeof createElement, + 352| +cloneElement: typeof cloneElement, + 353| +createFactory: typeof createFactory, + 354| +createRef: typeof createRef, + 355| +isValidElement: typeof isValidElement, + 356| +Component: typeof Component, + : + 358| +Fragment: typeof Fragment, + 359| +Children: typeof Children, + 360| +ConcurrentMode: typeof ConcurrentMode, + 361| +StrictMode: typeof StrictMode, + 362| +Suspense: typeof Suspense, + 363| +useContext: typeof useContext, + 364| +useState: typeof useState, + 365| +useReducer: typeof useReducer, + 366| +useRef: typeof useRef, + 367| +useEffect: typeof useEffect, + 368| +useLayoutEffect: typeof useLayoutEffect, + 369| +useCallback: typeof useCallback, + 370| +useMemo: typeof useMemo, + 371| +useImperativeMethods: typeof useImperativeMethods, + 372| |}; + -^ [1] + + +Error ----------------------------------------------------------------------------------- useMutationEffect_hook.js:12:3 + +Cannot call `React.useMutationEffect` because property `useMutationEffect` is missing in object type [1]. + + useMutationEffect_hook.js:12:3 + 12| React.useMutationEffect(() => {}, []); + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +References: + /react.js:342:26 + v- + 342| declare export default {| + 343| +DOM: typeof DOM, + 344| +PropTypes: typeof PropTypes, + 345| +version: typeof version, + 346| +checkPropTypes: typeof checkPropTypes, + 347| +memo: typeof memo, + 348| +lazy: typeof lazy, + 349| +createClass: typeof createClass, + 350| +createContext: typeof createContext, + 351| +createElement: typeof createElement, + 352| +cloneElement: typeof cloneElement, + 353| +createFactory: typeof createFactory, + 354| +createRef: typeof createRef, + 355| +isValidElement: typeof isValidElement, + 356| +Component: typeof Component, + : + 358| +Fragment: typeof Fragment, + 359| +Children: typeof Children, + 360| +ConcurrentMode: typeof ConcurrentMode, + 361| +StrictMode: typeof StrictMode, + 362| +Suspense: typeof Suspense, + 363| +useContext: typeof useContext, + 364| +useState: typeof useState, + 365| +useReducer: typeof useReducer, + 366| +useRef: typeof useRef, + 367| +useEffect: typeof useEffect, + 368| +useLayoutEffect: typeof useLayoutEffect, + 369| +useCallback: typeof useCallback, + 370| +useMemo: typeof useMemo, + 371| +useImperativeMethods: typeof useImperativeMethods, + 372| |}; + -^ [1] + + +Error ----------------------------------------------------------------------------------- useMutationEffect_hook.js:13:3 + +Cannot call `React.useMutationEffect` because property `useMutationEffect` is missing in object type [1]. + + useMutationEffect_hook.js:13:3 + 13| React.useMutationEffect(() => {}, [1, 2, 3]); + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +References: + /react.js:342:26 + v- + 342| declare export default {| + 343| +DOM: typeof DOM, + 344| +PropTypes: typeof PropTypes, + 345| +version: typeof version, + 346| +checkPropTypes: typeof checkPropTypes, + 347| +memo: typeof memo, + 348| +lazy: typeof lazy, + 349| +createClass: typeof createClass, + 350| +createContext: typeof createContext, + 351| +createElement: typeof createElement, + 352| +cloneElement: typeof cloneElement, + 353| +createFactory: typeof createFactory, + 354| +createRef: typeof createRef, + 355| +isValidElement: typeof isValidElement, + 356| +Component: typeof Component, + : + 358| +Fragment: typeof Fragment, + 359| +Children: typeof Children, + 360| +ConcurrentMode: typeof ConcurrentMode, + 361| +StrictMode: typeof StrictMode, + 362| +Suspense: typeof Suspense, + 363| +useContext: typeof useContext, + 364| +useState: typeof useState, + 365| +useReducer: typeof useReducer, + 366| +useRef: typeof useRef, + 367| +useEffect: typeof useEffect, + 368| +useLayoutEffect: typeof useLayoutEffect, + 369| +useCallback: typeof useCallback, + 370| +useMemo: typeof useMemo, + 371| +useImperativeMethods: typeof useImperativeMethods, + 372| |}; + -^ [1] + + +Error ----------------------------------------------------------------------------------- useMutationEffect_hook.js:16:3 + +Cannot call `React.useMutationEffect` because property `useMutationEffect` is missing in object type [1]. + + useMutationEffect_hook.js:16:3 + 16| React.useMutationEffect(() => () => {}); + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +References: + /react.js:342:26 + v- + 342| declare export default {| + 343| +DOM: typeof DOM, + 344| +PropTypes: typeof PropTypes, + 345| +version: typeof version, + 346| +checkPropTypes: typeof checkPropTypes, + 347| +memo: typeof memo, + 348| +lazy: typeof lazy, + 349| +createClass: typeof createClass, + 350| +createContext: typeof createContext, + 351| +createElement: typeof createElement, + 352| +cloneElement: typeof cloneElement, + 353| +createFactory: typeof createFactory, + 354| +createRef: typeof createRef, + 355| +isValidElement: typeof isValidElement, + 356| +Component: typeof Component, + : + 358| +Fragment: typeof Fragment, + 359| +Children: typeof Children, + 360| +ConcurrentMode: typeof ConcurrentMode, + 361| +StrictMode: typeof StrictMode, + 362| +Suspense: typeof Suspense, + 363| +useContext: typeof useContext, + 364| +useState: typeof useState, + 365| +useReducer: typeof useReducer, + 366| +useRef: typeof useRef, + 367| +useEffect: typeof useEffect, + 368| +useLayoutEffect: typeof useLayoutEffect, + 369| +useCallback: typeof useCallback, + 370| +useMemo: typeof useMemo, + 371| +useImperativeMethods: typeof useImperativeMethods, + 372| |}; + -^ [1] + + +Error ----------------------------------------------------------------------------------- useMutationEffect_hook.js:17:3 + +Cannot call `React.useMutationEffect` because property `useMutationEffect` is missing in object type [1]. + + useMutationEffect_hook.js:17:3 + 17| React.useMutationEffect(() => () => {}, []); + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +References: + /react.js:342:26 + v- + 342| declare export default {| + 343| +DOM: typeof DOM, + 344| +PropTypes: typeof PropTypes, + 345| +version: typeof version, + 346| +checkPropTypes: typeof checkPropTypes, + 347| +memo: typeof memo, + 348| +lazy: typeof lazy, + 349| +createClass: typeof createClass, + 350| +createContext: typeof createContext, + 351| +createElement: typeof createElement, + 352| +cloneElement: typeof cloneElement, + 353| +createFactory: typeof createFactory, + 354| +createRef: typeof createRef, + 355| +isValidElement: typeof isValidElement, + 356| +Component: typeof Component, + : + 358| +Fragment: typeof Fragment, + 359| +Children: typeof Children, + 360| +ConcurrentMode: typeof ConcurrentMode, + 361| +StrictMode: typeof StrictMode, + 362| +Suspense: typeof Suspense, + 363| +useContext: typeof useContext, + 364| +useState: typeof useState, + 365| +useReducer: typeof useReducer, + 366| +useRef: typeof useRef, + 367| +useEffect: typeof useEffect, + 368| +useLayoutEffect: typeof useLayoutEffect, + 369| +useCallback: typeof useCallback, + 370| +useMemo: typeof useMemo, + 371| +useImperativeMethods: typeof useImperativeMethods, + 372| |}; + -^ [1] + + +Error ----------------------------------------------------------------------------------- useMutationEffect_hook.js:18:3 + +Cannot call `React.useMutationEffect` because property `useMutationEffect` is missing in object type [1]. + + useMutationEffect_hook.js:18:3 + 18| React.useMutationEffect(() => () => {}, [1, 2, 3]); + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +References: + /react.js:342:26 + v- + 342| declare export default {| + 343| +DOM: typeof DOM, + 344| +PropTypes: typeof PropTypes, + 345| +version: typeof version, + 346| +checkPropTypes: typeof checkPropTypes, + 347| +memo: typeof memo, + 348| +lazy: typeof lazy, + 349| +createClass: typeof createClass, + 350| +createContext: typeof createContext, + 351| +createElement: typeof createElement, + 352| +cloneElement: typeof cloneElement, + 353| +createFactory: typeof createFactory, + 354| +createRef: typeof createRef, + 355| +isValidElement: typeof isValidElement, + 356| +Component: typeof Component, + : + 358| +Fragment: typeof Fragment, + 359| +Children: typeof Children, + 360| +ConcurrentMode: typeof ConcurrentMode, + 361| +StrictMode: typeof StrictMode, + 362| +Suspense: typeof Suspense, + 363| +useContext: typeof useContext, + 364| +useState: typeof useState, + 365| +useReducer: typeof useReducer, + 366| +useRef: typeof useRef, + 367| +useEffect: typeof useEffect, + 368| +useLayoutEffect: typeof useLayoutEffect, + 369| +useCallback: typeof useCallback, + 370| +useMemo: typeof useMemo, + 371| +useImperativeMethods: typeof useImperativeMethods, + 372| |}; + -^ [1] + + +Error ----------------------------------------------------------------------------------- useMutationEffect_hook.js:22:3 + +Cannot call `React.useMutationEffect` because property `useMutationEffect` is missing in object type [1]. + + useMutationEffect_hook.js:22:3 22| React.useMutationEffect(1); // Error: number is incompatible with function type - ^ [1] - -References: - /react.js:316:13 - 316| create: () => MaybeCleanUpFn, - ^^^^^^^^^^^^^^^^^^^^ [2] - - -Error ---------------------------------------------------------------------------------- useMutationEffect_hook.js:23:37 - -Cannot call `React.useMutationEffect` with `1` bound to `inputs` because number [1] is incompatible with read-only array -type [2]. - - useMutationEffect_hook.js:23:37 + ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +References: + /react.js:342:26 + v- + 342| declare export default {| + 343| +DOM: typeof DOM, + 344| +PropTypes: typeof PropTypes, + 345| +version: typeof version, + 346| +checkPropTypes: typeof checkPropTypes, + 347| +memo: typeof memo, + 348| +lazy: typeof lazy, + 349| +createClass: typeof createClass, + 350| +createContext: typeof createContext, + 351| +createElement: typeof createElement, + 352| +cloneElement: typeof cloneElement, + 353| +createFactory: typeof createFactory, + 354| +createRef: typeof createRef, + 355| +isValidElement: typeof isValidElement, + 356| +Component: typeof Component, + : + 358| +Fragment: typeof Fragment, + 359| +Children: typeof Children, + 360| +ConcurrentMode: typeof ConcurrentMode, + 361| +StrictMode: typeof StrictMode, + 362| +Suspense: typeof Suspense, + 363| +useContext: typeof useContext, + 364| +useState: typeof useState, + 365| +useReducer: typeof useReducer, + 366| +useRef: typeof useRef, + 367| +useEffect: typeof useEffect, + 368| +useLayoutEffect: typeof useLayoutEffect, + 369| +useCallback: typeof useCallback, + 370| +useMemo: typeof useMemo, + 371| +useImperativeMethods: typeof useImperativeMethods, + 372| |}; + -^ [1] + + +Error ----------------------------------------------------------------------------------- useMutationEffect_hook.js:23:3 + +Cannot call `React.useMutationEffect` because property `useMutationEffect` is missing in object type [1]. + + useMutationEffect_hook.js:23:3 23| React.useMutationEffect(() => {}, 1); // Error: number is incompatible with function react-only array - ^ [1] - -References: - /react.js:317:14 - 317| inputs: ?$ReadOnlyArray, - ^^^^^^^^^^^^^^^^^^^^^ [2] + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +References: + /react.js:342:26 + v- + 342| declare export default {| + 343| +DOM: typeof DOM, + 344| +PropTypes: typeof PropTypes, + 345| +version: typeof version, + 346| +checkPropTypes: typeof checkPropTypes, + 347| +memo: typeof memo, + 348| +lazy: typeof lazy, + 349| +createClass: typeof createClass, + 350| +createContext: typeof createContext, + 351| +createElement: typeof createElement, + 352| +cloneElement: typeof cloneElement, + 353| +createFactory: typeof createFactory, + 354| +createRef: typeof createRef, + 355| +isValidElement: typeof isValidElement, + 356| +Component: typeof Component, + : + 358| +Fragment: typeof Fragment, + 359| +Children: typeof Children, + 360| +ConcurrentMode: typeof ConcurrentMode, + 361| +StrictMode: typeof StrictMode, + 362| +Suspense: typeof Suspense, + 363| +useContext: typeof useContext, + 364| +useState: typeof useState, + 365| +useReducer: typeof useReducer, + 366| +useRef: typeof useRef, + 367| +useEffect: typeof useEffect, + 368| +useLayoutEffect: typeof useLayoutEffect, + 369| +useCallback: typeof useCallback, + 370| +useMemo: typeof useMemo, + 371| +useImperativeMethods: typeof useImperativeMethods, + 372| |}; + -^ [1] Error ------------------------------------------------------------------------------------------- useReducer_hook.js:6:3 @@ -3553,13 +3968,13 @@ Cannot call `React.useReducer` because function [1] requires another argument. ^^^^^^^^^^^^^^^^^^ References: - /react.js:302:37 + /react.js:308:37 v------ - 302| declare export function useReducer( - 303| reducer: (S, A) => S, - 304| initialState: S, - 305| initialAction: ?A, - 306| ): [S, A => void]; + 308| declare export function useReducer( + 309| reducer: (S, A) => S, + 310| initialState: S, + 311| initialAction: ?A, + 312| ): [S, A => void]; ----------------^ [1] @@ -3703,7 +4118,7 @@ References: -Found 230 errors +Found 238 errors Only showing the most relevant union/intersection branches. To see all branches, re-run Flow with --show-all-branches diff --git a/tests/react/useCallback_hook.js b/tests/react/useCallback_hook.js index af67b7f1606..0e552b4df29 100644 --- a/tests/react/useCallback_hook.js +++ b/tests/react/useCallback_hook.js @@ -7,10 +7,17 @@ import React from 'react'; } { - let numeric: number; - numeric = React.useCallback(() => 123); // Ok - numeric = React.useCallback(() => 123, []); // Ok - numeric = React.useCallback(() => 123, [1, 2, 3]); // Ok - numeric = React.useCallback(() => 'abc'); // Error: is incompatible with number - numeric = React.useCallback(() => 123, {}); // Error: object literal is incompatible with +read-only array type + const callback = React.useCallback(() => 123); + const num: number = callback(); + const str: string = callback();// Error: number is incompatible with string. +} + +{ + const callback = React.useCallback((num: number, str: string) => { + (num: number); + (str: string); + }); + callback(123, 'abc'); // Ok + callback(true); // Error: function requires another argument. + callback('123', 'abc'); // Error: string is incompatible with number. } diff --git a/tests/react_16_6/Suspense.js b/tests/react_16_6/Suspense.js new file mode 100644 index 00000000000..3e226fa50e3 --- /dev/null +++ b/tests/react_16_6/Suspense.js @@ -0,0 +1,49 @@ +// @flow + +import React from 'react'; + +const {Suspense} = React; + +function Loading() { + return

Loading...
; +} + +{ + } maxDuration="abc" /> // Error: string is incompatible with number +} + +{ + // Error: function is incompatible with exact React.Element +} + +{ + } /> +} + +{ + } maxDuration={1000} /> +} + +{ + } maxDuration={1000}> +
Hello
+
+} + +{ + }> + + +} + +{ + }> + + +} + +{ + }> + + +} diff --git a/tests/react_16_6/lazy.js b/tests/react_16_6/lazy.js index b0286bae9ee..decea1d3ee1 100644 --- a/tests/react_16_6/lazy.js +++ b/tests/react_16_6/lazy.js @@ -6,14 +6,23 @@ type Props = {| foo: number |}; function FunctionComponent(x: Props): React.Node { return null } class ClassComponent extends React.Component {} -const LazyFunctionComponent = React.lazy( () => FunctionComponent ); +React.lazy(() => FunctionComponent); // Error incompatible with Promise +React.lazy(() => ClassComponent); // Error incompatible with Promise +React.lazy(() => Promise.resolve(FunctionComponent)); // Error property default is missing +React.lazy(() => Promise.resolve(ClassComponent)); // Error property default is missing + +const LazyFunctionComponent = React.lazy( + () => Promise.resolve({default: FunctionComponent}) +); const _a = ; const _b = ; // Error missing foo const _c = ; // Error extra bar const _d = ; // Error wrong type for foo -const LazyClassComponent = React.lazy( () => ClassComponent ); +const LazyClassComponent = React.lazy( + () => Promise.resolve({default: ClassComponent}) +); const _e = ; const _f = ; // Error missing foo diff --git a/tests/react_16_6/react_16_6.exp b/tests/react_16_6/react_16_6.exp index 5b118552ffe..2d938783074 100644 --- a/tests/react_16_6/react_16_6.exp +++ b/tests/react_16_6/react_16_6.exp @@ -1,9 +1,130 @@ +Error ------------------------------------------------------------------------------------------------- Suspense.js:12:3 + +Cannot create `Suspense` element because string [1] is incompatible with number [2] in property `maxDuration`. + + Suspense.js:12:3 + 12| } maxDuration="abc" /> // Error: string is incompatible with number + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +References: + Suspense.js:12:48 + 12| } maxDuration="abc" /> // Error: string is incompatible with number + ^^^^^ [1] + /react.js:264:19 + 264| maxDuration?: number + ^^^^^^ [2] + + +Error ------------------------------------------------------------------------------------------------- Suspense.js:16:3 + +Cannot create `Suspense` element because in property `fallback`: + - Either inexact function [1] is incompatible with exact `React.Element` [2]. + - Or function [1] is incompatible with `React.Portal` [3]. + - Or property `@@iterator` is missing in function [1] but exists in `$Iterable` [4]. + + Suspense.js:16:3 + 16| // Error: function is incompatible with exact React.Element + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +References: + Suspense.js:7:1 + 7| function Loading() { + ^^^^^^^^^^^^^^^^^^ [1] + /react.js:18:5 + 18| | React$Element + ^^^^^^^^^^^^^^^^^^ [2] + /react.js:19:5 + 19| | React$Portal + ^^^^^^^^^^^^ [3] + /react.js:20:5 + 20| | Iterable; + ^^^^^^^^^^^^^^^^^^^^^ [4] + + +Error ----------------------------------------------------------------------------------------------------- lazy.js:9:12 + +Cannot call `React.lazy` with function bound to `component` because function [1] is incompatible with `Promise` [2] in +the return value. + + lazy.js:9:12 + 9| React.lazy(() => FunctionComponent); // Error incompatible with Promise + ^^^^^^^^^^^^^^^^^^^^^^^ + +References: + lazy.js:6:1 + 6| function FunctionComponent(x: Props): React.Node { return null } + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [1] + /react.js:294:22 + 294| component: () => Promise<{ default: React$ComponentType

}>, + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2] + + +Error ---------------------------------------------------------------------------------------------------- lazy.js:10:12 + +Cannot call `React.lazy` with function bound to `component` because class `ClassComponent` [1] is incompatible with +`Promise` [2] in the return value. + + lazy.js:10:12 + 10| React.lazy(() => ClassComponent); // Error incompatible with Promise + ^^^^^^^^^^^^^^^^^^^^ + +References: + lazy.js:7:7 + 7| class ClassComponent extends React.Component {} + ^^^^^^^^^^^^^^ [1] + /react.js:294:22 + 294| component: () => Promise<{ default: React$ComponentType

}>, + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2] + + +Error ---------------------------------------------------------------------------------------------------- lazy.js:11:12 + +Cannot call `React.lazy` with function bound to `component` because property `default` is missing in function [1] but +exists in object type [2] in type argument `R` [3] of the return value. + + lazy.js:11:12 + 11| React.lazy(() => Promise.resolve(FunctionComponent)); // Error property default is missing + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +References: + lazy.js:6:1 + 6| function FunctionComponent(x: Props): React.Node { return null } + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [1] + /react.js:294:30 + 294| component: () => Promise<{ default: React$ComponentType

}>, + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2] + /core.js:612:24 + 612| declare class Promise<+R> { + ^ [3] + + Error ---------------------------------------------------------------------------------------------------- lazy.js:12:12 -Cannot create `LazyFunctionComponent` element because property `foo` is missing in props [1] but exists in `Props` [2]. +Cannot call `React.lazy` with function bound to `component` because property `default` is missing in statics of +`ClassComponent` [1] but exists in object type [2] in type argument `R` [3] of the return value. lazy.js:12:12 - 12| const _b = ; // Error missing foo + 12| React.lazy(() => Promise.resolve(ClassComponent)); // Error property default is missing + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +References: + lazy.js:7:7 + 7| class ClassComponent extends React.Component {} + ^^^^^^^^^^^^^^ [1] + /react.js:294:30 + 294| component: () => Promise<{ default: React$ComponentType

}>, + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2] + /core.js:612:24 + 612| declare class Promise<+R> { + ^ [3] + + +Error ---------------------------------------------------------------------------------------------------- lazy.js:19:12 + +Cannot create `LazyFunctionComponent` element because property `foo` is missing in props [1] but exists in `Props` [2]. + + lazy.js:19:12 + 19| const _b = ; // Error missing foo ^^^^^^^^^^^^^^^^^^^^^^^^^ [1] References: @@ -12,12 +133,12 @@ References: ^^^^^ [2] -Error ---------------------------------------------------------------------------------------------------- lazy.js:13:12 +Error ---------------------------------------------------------------------------------------------------- lazy.js:20:12 Cannot create `LazyFunctionComponent` element because property `bar` is missing in `Props` [1] but exists in props [2]. - lazy.js:13:12 - 13| const _c = ; // Error extra bar + lazy.js:20:12 + 20| const _c = ; // Error extra bar ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2] References: @@ -26,29 +147,29 @@ References: ^^^^^ [1] -Error ---------------------------------------------------------------------------------------------------- lazy.js:14:12 +Error ---------------------------------------------------------------------------------------------------- lazy.js:21:12 Cannot create `LazyFunctionComponent` element because string [1] is incompatible with number [2] in property `foo`. - lazy.js:14:12 - 14| const _d = ; // Error wrong type for foo + lazy.js:21:12 + 21| const _d = ; // Error wrong type for foo ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ References: - lazy.js:14:39 - 14| const _d = ; // Error wrong type for foo + lazy.js:21:39 + 21| const _d = ; // Error wrong type for foo ^^^^^^^^ [1] lazy.js:5:22 5| type Props = {| foo: number |}; ^^^^^^ [2] -Error ---------------------------------------------------------------------------------------------------- lazy.js:19:12 +Error ---------------------------------------------------------------------------------------------------- lazy.js:28:12 Cannot create `LazyClassComponent` element because property `foo` is missing in props [1] but exists in `Props` [2]. - lazy.js:19:12 - 19| const _f = ; // Error missing foo + lazy.js:28:12 + 28| const _f = ; // Error missing foo ^^^^^^^^^^^^^^^^^^^^^^ [1] References: @@ -57,12 +178,12 @@ References: ^^^^^ [2] -Error ---------------------------------------------------------------------------------------------------- lazy.js:20:12 +Error ---------------------------------------------------------------------------------------------------- lazy.js:29:12 Cannot create `LazyClassComponent` element because property `bar` is missing in `Props` [1] but exists in props [2]. - lazy.js:20:12 - 20| const _g = ; // Error extra bar + lazy.js:29:12 + 29| const _g = ; // Error extra bar ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2] References: @@ -71,17 +192,17 @@ References: ^^^^^ [1] -Error ---------------------------------------------------------------------------------------------------- lazy.js:21:12 +Error ---------------------------------------------------------------------------------------------------- lazy.js:30:12 Cannot create `LazyClassComponent` element because string [1] is incompatible with number [2] in property `foo`. - lazy.js:21:12 - 21| const _h = ; // Error wrong type for foo + lazy.js:30:12 + 30| const _h = ; // Error wrong type for foo ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ References: - lazy.js:21:36 - 21| const _h = ; // Error wrong type for foo + lazy.js:30:36 + 30| const _h = ; // Error wrong type for foo ^^^^^^^^ [1] lazy.js:5:22 5| type Props = {| foo: number |}; @@ -179,4 +300,7 @@ References: -Found 12 errors +Found 18 errors + +Only showing the most relevant union/intersection branches. +To see all branches, re-run Flow with --show-all-branches diff --git a/tests/react_children/react_children.exp b/tests/react_children/react_children.exp index 61aa7db4a83..56f7045f88a 100644 --- a/tests/react_children/react_children.exp +++ b/tests/react_children/react_children.exp @@ -68,8 +68,8 @@ References: api.js:14:25 14| Children.forEach(a, (x: number) => {}); // Error ^^^^^^ [2] - /react.js:265:38 - 265| declare export type ChildrenArray<+T> = $ReadOnlyArray> | T; + /react.js:271:38 + 271| declare export type ChildrenArray<+T> = $ReadOnlyArray> | T; ^ [3] @@ -90,8 +90,8 @@ References: api.js:16:25 16| Children.forEach(a, (x: string) => {}); // Error ^^^^^^ [2] - /react.js:265:38 - 265| declare export type ChildrenArray<+T> = $ReadOnlyArray> | T; + /react.js:271:38 + 271| declare export type ChildrenArray<+T> = $ReadOnlyArray> | T; ^ [3] api.js:5:25 5| const a: ChildrenArray = [ @@ -107,8 +107,8 @@ Cannot call `s` with `Children.count(...)` bound to `x` because number [1] is in ^^^^^^^^^^^^^^^^^ References: - /react.js:277:42 - 277| count(children: ChildrenArray): number; + /react.js:283:42 + 283| count(children: ChildrenArray): number; ^^^^^^ [1] api.js:29:15 29| function s(x: string) {} diff --git a/tests/react_imports/react_imports.exp b/tests/react_imports/react_imports.exp index b909f6ef4a5..edb6446f015 100644 --- a/tests/react_imports/react_imports.exp +++ b/tests/react_imports/react_imports.exp @@ -47,8 +47,8 @@ Cannot get `React.Missing` because property `Missing` is missing in module `reac ^^^^^^^^^^^^^ References: - /react.js:377:27 - 377| declare module.exports: $Exports<'react'>; + /react.js:378:27 + 378| declare module.exports: $Exports<'react'>; ^^^^^^^^^^^^^^^^^ [1] @@ -155,8 +155,8 @@ Cannot get `React.Missing` because property `Missing` is missing in module `reac ^^^^^^^^^^^^^ References: - /react.js:377:27 - 377| declare module.exports: $Exports<'react'>; + /react.js:378:27 + 378| declare module.exports: $Exports<'react'>; ^^^^^^^^^^^^^^^^^ [1] @@ -186,39 +186,39 @@ Cannot get `React.Node` because property `Node` is missing in object type [1]. ^^^^^^^^^^ References: - /react.js:341:26 + /react.js:342:26 v- - 341| declare export default {| - 342| +DOM: typeof DOM, - 343| +PropTypes: typeof PropTypes, - 344| +version: typeof version, - 345| +checkPropTypes: typeof checkPropTypes, - 346| +memo: typeof memo, - 347| +lazy: typeof lazy, - 348| +createClass: typeof createClass, - 349| +createContext: typeof createContext, - 350| +createElement: typeof createElement, - 351| +cloneElement: typeof cloneElement, - 352| +createFactory: typeof createFactory, - 353| +createRef: typeof createRef, - 354| +isValidElement: typeof isValidElement, - 355| +Component: typeof Component, + 342| declare export default {| + 343| +DOM: typeof DOM, + 344| +PropTypes: typeof PropTypes, + 345| +version: typeof version, + 346| +checkPropTypes: typeof checkPropTypes, + 347| +memo: typeof memo, + 348| +lazy: typeof lazy, + 349| +createClass: typeof createClass, + 350| +createContext: typeof createContext, + 351| +createElement: typeof createElement, + 352| +cloneElement: typeof cloneElement, + 353| +createFactory: typeof createFactory, + 354| +createRef: typeof createRef, + 355| +isValidElement: typeof isValidElement, + 356| +Component: typeof Component, : - 357| +Fragment: typeof Fragment, - 358| +Children: typeof Children, - 359| +ConcurrentMode: typeof ConcurrentMode, - 360| +StrictMode: typeof StrictMode, - 361| +useContext: typeof useContext, - 362| +useState: typeof useState, - 363| +useReducer: typeof useReducer, - 364| +useRef: typeof useRef, - 365| +useEffect: typeof useEffect, - 366| +useMutationEffect: typeof useMutationEffect, - 367| +useLayoutEffect: typeof useLayoutEffect, - 368| +useCallback: typeof useCallback, - 369| +useMemo: typeof useMemo, - 370| +useImperativeMethods: typeof useImperativeMethods, - 371| |}; + 358| +Fragment: typeof Fragment, + 359| +Children: typeof Children, + 360| +ConcurrentMode: typeof ConcurrentMode, + 361| +StrictMode: typeof StrictMode, + 362| +Suspense: typeof Suspense, + 363| +useContext: typeof useContext, + 364| +useState: typeof useState, + 365| +useReducer: typeof useReducer, + 366| +useRef: typeof useRef, + 367| +useEffect: typeof useEffect, + 368| +useLayoutEffect: typeof useLayoutEffect, + 369| +useCallback: typeof useCallback, + 370| +useMemo: typeof useMemo, + 371| +useImperativeMethods: typeof useImperativeMethods, + 372| |}; -^ [1] @@ -231,39 +231,39 @@ Cannot get `React.Node` because property `Node` is missing in object type [1]. ^^^^^^^^^^ References: - /react.js:341:26 + /react.js:342:26 v- - 341| declare export default {| - 342| +DOM: typeof DOM, - 343| +PropTypes: typeof PropTypes, - 344| +version: typeof version, - 345| +checkPropTypes: typeof checkPropTypes, - 346| +memo: typeof memo, - 347| +lazy: typeof lazy, - 348| +createClass: typeof createClass, - 349| +createContext: typeof createContext, - 350| +createElement: typeof createElement, - 351| +cloneElement: typeof cloneElement, - 352| +createFactory: typeof createFactory, - 353| +createRef: typeof createRef, - 354| +isValidElement: typeof isValidElement, - 355| +Component: typeof Component, + 342| declare export default {| + 343| +DOM: typeof DOM, + 344| +PropTypes: typeof PropTypes, + 345| +version: typeof version, + 346| +checkPropTypes: typeof checkPropTypes, + 347| +memo: typeof memo, + 348| +lazy: typeof lazy, + 349| +createClass: typeof createClass, + 350| +createContext: typeof createContext, + 351| +createElement: typeof createElement, + 352| +cloneElement: typeof cloneElement, + 353| +createFactory: typeof createFactory, + 354| +createRef: typeof createRef, + 355| +isValidElement: typeof isValidElement, + 356| +Component: typeof Component, : - 357| +Fragment: typeof Fragment, - 358| +Children: typeof Children, - 359| +ConcurrentMode: typeof ConcurrentMode, - 360| +StrictMode: typeof StrictMode, - 361| +useContext: typeof useContext, - 362| +useState: typeof useState, - 363| +useReducer: typeof useReducer, - 364| +useRef: typeof useRef, - 365| +useEffect: typeof useEffect, - 366| +useMutationEffect: typeof useMutationEffect, - 367| +useLayoutEffect: typeof useLayoutEffect, - 368| +useCallback: typeof useCallback, - 369| +useMemo: typeof useMemo, - 370| +useImperativeMethods: typeof useImperativeMethods, - 371| |}; + 358| +Fragment: typeof Fragment, + 359| +Children: typeof Children, + 360| +ConcurrentMode: typeof ConcurrentMode, + 361| +StrictMode: typeof StrictMode, + 362| +Suspense: typeof Suspense, + 363| +useContext: typeof useContext, + 364| +useState: typeof useState, + 365| +useReducer: typeof useReducer, + 366| +useRef: typeof useRef, + 367| +useEffect: typeof useEffect, + 368| +useLayoutEffect: typeof useLayoutEffect, + 369| +useCallback: typeof useCallback, + 370| +useMemo: typeof useMemo, + 371| +useImperativeMethods: typeof useImperativeMethods, + 372| |}; -^ [1] @@ -276,39 +276,39 @@ Cannot get `React.Missing` because property `Missing` is missing in object type ^^^^^^^^^^^^^ References: - /react.js:341:26 + /react.js:342:26 v- - 341| declare export default {| - 342| +DOM: typeof DOM, - 343| +PropTypes: typeof PropTypes, - 344| +version: typeof version, - 345| +checkPropTypes: typeof checkPropTypes, - 346| +memo: typeof memo, - 347| +lazy: typeof lazy, - 348| +createClass: typeof createClass, - 349| +createContext: typeof createContext, - 350| +createElement: typeof createElement, - 351| +cloneElement: typeof cloneElement, - 352| +createFactory: typeof createFactory, - 353| +createRef: typeof createRef, - 354| +isValidElement: typeof isValidElement, - 355| +Component: typeof Component, + 342| declare export default {| + 343| +DOM: typeof DOM, + 344| +PropTypes: typeof PropTypes, + 345| +version: typeof version, + 346| +checkPropTypes: typeof checkPropTypes, + 347| +memo: typeof memo, + 348| +lazy: typeof lazy, + 349| +createClass: typeof createClass, + 350| +createContext: typeof createContext, + 351| +createElement: typeof createElement, + 352| +cloneElement: typeof cloneElement, + 353| +createFactory: typeof createFactory, + 354| +createRef: typeof createRef, + 355| +isValidElement: typeof isValidElement, + 356| +Component: typeof Component, : - 357| +Fragment: typeof Fragment, - 358| +Children: typeof Children, - 359| +ConcurrentMode: typeof ConcurrentMode, - 360| +StrictMode: typeof StrictMode, - 361| +useContext: typeof useContext, - 362| +useState: typeof useState, - 363| +useReducer: typeof useReducer, - 364| +useRef: typeof useRef, - 365| +useEffect: typeof useEffect, - 366| +useMutationEffect: typeof useMutationEffect, - 367| +useLayoutEffect: typeof useLayoutEffect, - 368| +useCallback: typeof useCallback, - 369| +useMemo: typeof useMemo, - 370| +useImperativeMethods: typeof useImperativeMethods, - 371| |}; + 358| +Fragment: typeof Fragment, + 359| +Children: typeof Children, + 360| +ConcurrentMode: typeof ConcurrentMode, + 361| +StrictMode: typeof StrictMode, + 362| +Suspense: typeof Suspense, + 363| +useContext: typeof useContext, + 364| +useState: typeof useState, + 365| +useReducer: typeof useReducer, + 366| +useRef: typeof useRef, + 367| +useEffect: typeof useEffect, + 368| +useLayoutEffect: typeof useLayoutEffect, + 369| +useCallback: typeof useCallback, + 370| +useMemo: typeof useMemo, + 371| +useImperativeMethods: typeof useImperativeMethods, + 372| |}; -^ [1] diff --git a/tests/react_jsx/react_jsx.exp b/tests/react_jsx/react_jsx.exp index 4b3a60e1cf5..74fd92e67c6 100644 --- a/tests/react_jsx/react_jsx.exp +++ b/tests/react_jsx/react_jsx.exp @@ -93,8 +93,8 @@ References: test.js:105:12 105| string1={null} ^^^^ [1] - /react.js:412:36 - 412| string: React$PropType$Primitive; + /react.js:413:36 + 413| string: React$PropType$Primitive; ^^^^^^ [2] test.js:106:12 106| string2={null} @@ -102,8 +102,8 @@ References: test.js:107:13 107| boolean1={null} ^^^^ [4] - /react.js:408:34 - 408| bool: React$PropType$Primitive; + /react.js:409:34 + 409| bool: React$PropType$Primitive; ^^^^^^^ [5] test.js:108:13 108| boolean2={null} @@ -111,8 +111,8 @@ References: test.js:109:11 109| number={null} ^^^^ [7] - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [8] @@ -161,8 +161,8 @@ References: test.js:135:54 135| {...{string1: 'foo', string2: 'bar', number: (any: ?number)}} ^^^^^^^ [1] - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [2] @@ -1654,8 +1654,8 @@ References: /core.js:13:24 13| declare var undefined: void; ^^^^ [1] - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [2] @@ -1675,8 +1675,8 @@ References: test.js:788:7 788| foo="nope" ^^^^^^ [1] - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [2] @@ -1696,8 +1696,8 @@ References: test.js:793:7 793| bar="nope" ^^^^^^ [1] - /react.js:410:36 - 410| number: React$PropType$Primitive; + /react.js:411:36 + 411| number: React$PropType$Primitive; ^^^^^^ [2] diff --git a/tests/type-at-pos_react/type-at-pos_react.exp b/tests/type-at-pos_react/type-at-pos_react.exp index 9f34aefad77..7e58c972231 100644 --- a/tests/type-at-pos_react/type-at-pos_react.exp +++ b/tests/type-at-pos_react/type-at-pos_react.exp @@ -1,5 +1,5 @@ react_component.js:3:9 = { - "type":"{|+Children: {+count: (children: ChildrenArray) => number, +forEach: (children: ChildrenArray, fn: (child: T, index: number) => mixed, thisArg?: mixed) => void, +map: (children: ChildrenArray, fn: (child: $NonMaybeType, index: number) => U, thisArg?: mixed) => Array<$NonMaybeType>, +only: (children: ChildrenArray) => $NonMaybeType, +toArray: (children: ChildrenArray) => Array<$NonMaybeType>}, +ChildrenArray: type ChildrenArray<+T> = $ReadOnlyArray> | T, +Component: class React$Component, +ComponentType: type ComponentType

= React$ComponentType

, +ConcurrentMode: ({children: ?React$Node}) => React$Node, +Context: type Context = React$Context, +DOM: any, +Element: type Element<+C> = React$Element, +ElementConfig: type ElementConfig = React$ElementConfig, +ElementProps: type ElementProps = React$ElementProps, +ElementRef: type ElementRef = React$ElementRef, +ElementType: type ElementType = React$ElementType, +Fragment: ({children: ?React$Node}) => React$Node, +Key: type Key = React$Key, +Node: type Node = React$Node, +Portal: type Portal = React$Portal, +PropTypes: ReactPropTypes, +PureComponent: class React$PureComponent, +Ref: type Ref = React$Ref, +StatelessFunctionalComponent: type StatelessFunctionalComponent

= React$StatelessFunctionalComponent

, +StrictMode: ({children: ?React$Node}) => React$Node, +checkPropTypes: (propTypes: $Subtype<{[_: $Keys]: ReactPropsCheckType}>, values: V, location: string, componentName: string, getStack: ?(() => ?string)) => void, +cloneElement: React$CloneElement, +createClass: React$CreateClass, +createContext: (defaultValue: T, calculateChangedBits: ?((a: T, b: T) => number)) => React$Context, +createElement: React$CreateElement, +createFactory: (type: ElementType) => React$ElementFactory, +createRef: () => {current: (null | T)}, +default: {|+Children: {+count: (children: ChildrenArray) => number, +forEach: (children: ChildrenArray, fn: (child: T, index: number) => mixed, thisArg?: mixed) => void, +map: (children: ChildrenArray, fn: (child: $NonMaybeType, index: number) => U, thisArg?: mixed) => Array<$NonMaybeType>, +only: (children: ChildrenArray) => $NonMaybeType, +toArray: (children: ChildrenArray) => Array<$NonMaybeType>}, +Component: class React$Component, +ConcurrentMode: ({children: ?React$Node}) => React$Node, +DOM: any, +Fragment: ({children: ?React$Node}) => React$Node, +PropTypes: ReactPropTypes, +PureComponent: class React$PureComponent, +StrictMode: ({children: ?React$Node}) => React$Node, +checkPropTypes: (propTypes: $Subtype<{[_: $Keys]: ReactPropsCheckType}>, values: V, location: string, componentName: string, getStack: ?(() => ?string)) => void, +cloneElement: React$CloneElement, +createClass: React$CreateClass, +createContext: (defaultValue: T, calculateChangedBits: ?((a: T, b: T) => number)) => React$Context, +createElement: React$CreateElement, +createFactory: (type: ElementType) => React$ElementFactory, +createRef: () => {current: (null | T)}, +isValidElement: (element: any) => boolean, +lazy:

(component: () => React$ComponentType

) => React$ComponentType

, +memo:

(component: React$StatelessFunctionalComponent

, equal?: (P, P) => boolean) => React$StatelessFunctionalComponent

, +useCallback: (callback: () => (T | void), inputs: ?$ReadOnlyArray) => T, +useContext: (context: React$Context, observedBits: (void | number | boolean)) => T, +useEffect: (create: () => MaybeCleanUpFn, inputs: ?$ReadOnlyArray) => void, +useImperativeMethods: (ref: ?({current: (T | null)} | ((inst: (T | null)) => mixed)), create: () => T, inputs: ?$ReadOnlyArray) => void, +useLayoutEffect: (create: () => MaybeCleanUpFn, inputs: ?$ReadOnlyArray) => void, +useMemo: (create: () => T, inputs: ?$ReadOnlyArray) => T, +useMutationEffect: (create: () => MaybeCleanUpFn, inputs: ?$ReadOnlyArray) => void, +useReducer: (reducer: (S, A) => S, initialState: S, initialAction: ?A) => [S, (A) => void], +useRef: (initialValue: ?T) => {current: (T | null)}, +useState: (initialState: ((() => S) | S)) => [S, ((((S) => S) | S)) => void], +version: string|}, +isValidElement: (element: any) => boolean, +lazy:

(component: () => React$ComponentType

) => React$ComponentType

, +memo:

(component: React$StatelessFunctionalComponent

, equal?: (P, P) => boolean) => React$StatelessFunctionalComponent

, +useCallback: (callback: () => (T | void), inputs: ?$ReadOnlyArray) => T, +useContext: (context: React$Context, observedBits: (void | number | boolean)) => T, +useEffect: (create: () => MaybeCleanUpFn, inputs: ?$ReadOnlyArray) => void, +useImperativeMethods: (ref: ?({current: (T | null)} | ((inst: (T | null)) => mixed)), create: () => T, inputs: ?$ReadOnlyArray) => void, +useLayoutEffect: (create: () => MaybeCleanUpFn, inputs: ?$ReadOnlyArray) => void, +useMemo: (create: () => T, inputs: ?$ReadOnlyArray) => T, +useMutationEffect: (create: () => MaybeCleanUpFn, inputs: ?$ReadOnlyArray) => void, +useReducer: (reducer: (S, A) => S, initialState: S, initialAction: ?A) => [S, (A) => void], +useRef: (initialValue: ?T) => {current: (T | null)}, +useState: (initialState: ((() => S) | S)) => [S, ((((S) => S) | S)) => void], +version: string|}", + "type":"{|+Children: {+count: (children: ChildrenArray) => number, +forEach: (children: ChildrenArray, fn: (child: T, index: number) => mixed, thisArg?: mixed) => void, +map: (children: ChildrenArray, fn: (child: $NonMaybeType, index: number) => U, thisArg?: mixed) => Array<$NonMaybeType>, +only: (children: ChildrenArray) => $NonMaybeType, +toArray: (children: ChildrenArray) => Array<$NonMaybeType>}, +ChildrenArray: type ChildrenArray<+T> = $ReadOnlyArray> | T, +Component: class React$Component, +ComponentType: type ComponentType

= React$ComponentType

, +ConcurrentMode: ({children: ?React$Node}) => React$Node, +Context: type Context = React$Context, +DOM: any, +Element: type Element<+C> = React$Element, +ElementConfig: type ElementConfig = React$ElementConfig, +ElementProps: type ElementProps = React$ElementProps, +ElementRef: type ElementRef = React$ElementRef, +ElementType: type ElementType = React$ElementType, +Fragment: ({children: ?React$Node}) => React$Node, +Key: type Key = React$Key, +Node: type Node = React$Node, +Portal: type Portal = React$Portal, +PropTypes: ReactPropTypes, +PureComponent: class React$PureComponent, +Ref: type Ref = React$Ref, +StatelessFunctionalComponent: type StatelessFunctionalComponent

= React$StatelessFunctionalComponent

, +StrictMode: ({children: ?React$Node}) => React$Node, +Suspense: React$ComponentType<{children?: ?React$Node, fallback?: React$Node, maxDuration?: number}>, +checkPropTypes: (propTypes: $Subtype<{[_: $Keys]: ReactPropsCheckType}>, values: V, location: string, componentName: string, getStack: ?(() => ?string)) => void, +cloneElement: React$CloneElement, +createClass: React$CreateClass, +createContext: (defaultValue: T, calculateChangedBits: ?((a: T, b: T) => number)) => React$Context, +createElement: React$CreateElement, +createFactory: (type: ElementType) => React$ElementFactory, +createRef: () => {current: (null | T)}, +default: {|+Children: {+count: (children: ChildrenArray) => number, +forEach: (children: ChildrenArray, fn: (child: T, index: number) => mixed, thisArg?: mixed) => void, +map: (children: ChildrenArray, fn: (child: $NonMaybeType, index: number) => U, thisArg?: mixed) => Array<$NonMaybeType>, +only: (children: ChildrenArray) => $NonMaybeType, +toArray: (children: ChildrenArray) => Array<$NonMaybeType>}, +Component: class React$Component, +ConcurrentMode: ({children: ?React$Node}) => React$Node, +DOM: any, +Fragment: ({children: ?React$Node}) => React$Node, +PropTypes: ReactPropTypes, +PureComponent: class React$PureComponent, +StrictMode: ({children: ?React$Node}) => React$Node, +Suspense: React$ComponentType<{children?: ?React$Node, fallback?: React$Node, maxDuration?: number}>, +checkPropTypes: (propTypes: $Subtype<{[_: $Keys]: ReactPropsCheckType}>, values: V, location: string, componentName: string, getStack: ?(() => ?string)) => void, +cloneElement: React$CloneElement, +createClass: React$CreateClass, +createContext: (defaultValue: T, calculateChangedBits: ?((a: T, b: T) => number)) => React$Context, +createElement: React$CreateElement, +createFactory: (type: ElementType) => React$ElementFactory, +createRef: () => {current: (null | T)}, +isValidElement: (element: any) => boolean, +lazy:

(component: () => Promise<{default: React$ComponentType

}>) => React$ComponentType

, +memo:

(component: React$StatelessFunctionalComponent

, equal?: (P, P) => boolean) => React$StatelessFunctionalComponent

, +useCallback: ) => mixed>(callback: T, inputs: ?$ReadOnlyArray) => T, +useContext: (context: React$Context, observedBits: (void | number | boolean)) => T, +useEffect: (create: () => MaybeCleanUpFn, inputs: ?$ReadOnlyArray) => void, +useImperativeMethods: (ref: ?({current: (T | null)} | ((inst: (T | null)) => mixed)), create: () => T, inputs: ?$ReadOnlyArray) => void, +useLayoutEffect: (create: () => MaybeCleanUpFn, inputs: ?$ReadOnlyArray) => void, +useMemo: (create: () => T, inputs: ?$ReadOnlyArray) => T, +useReducer: (reducer: (S, A) => S, initialState: S, initialAction: ?A) => [S, (A) => void], +useRef: (initialValue: ?T) => {current: (T | null)}, +useState: (initialState: ((() => S) | S)) => [S, ((((S) => S) | S)) => void], +version: string|}, +isValidElement: (element: any) => boolean, +lazy:

(component: () => Promise<{default: React$ComponentType

}>) => React$ComponentType

, +memo:

(component: React$StatelessFunctionalComponent

, equal?: (P, P) => boolean) => React$StatelessFunctionalComponent

, +useCallback: ) => mixed>(callback: T, inputs: ?$ReadOnlyArray) => T, +useContext: (context: React$Context, observedBits: (void | number | boolean)) => T, +useEffect: (create: () => MaybeCleanUpFn, inputs: ?$ReadOnlyArray) => void, +useImperativeMethods: (ref: ?({current: (T | null)} | ((inst: (T | null)) => mixed)), create: () => T, inputs: ?$ReadOnlyArray) => void, +useLayoutEffect: (create: () => MaybeCleanUpFn, inputs: ?$ReadOnlyArray) => void, +useMemo: (create: () => T, inputs: ?$ReadOnlyArray) => T, +useReducer: (reducer: (S, A) => S, initialState: S, initialAction: ?A) => [S, (A) => void], +useRef: (initialValue: ?T) => {current: (T | null)}, +useState: (initialState: ((() => S) | S)) => [S, ((((S) => S) | S)) => void], +version: string|}", "reasons":[], "loc":{ "source":"react_component.js",