Skip to content

Commit

Permalink
[flow][tests] Remove tests on React.Config
Browse files Browse the repository at this point in the history
Summary:
Prepare for the eventual removal in v0.256

Changelog: [internal]

Reviewed By: panagosg7

Differential Revision: D66380514

fbshipit-source-id: 98d75db646d6d94fedef9177fe14aed85cd5dce5
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Nov 22, 2024
1 parent 601dd02 commit efe3518
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 339 deletions.
106 changes: 26 additions & 80 deletions tests/component_type/component_type.exp
Original file line number Diff line number Diff line change
Expand Up @@ -327,114 +327,60 @@ References:
^ [3]


Error ----------------------------------------------------------------------------------------------- config_HOC.js:13:1
Error ----------------------------------------------------------------------------------------------- config_HOC.js:10:1

Cannot cast `y` to `NotTheRightConfig` because property `baz` is missing in `Props` [1] but exists in
Cannot cast `x` to `NotTheRightConfig` because property `baz` is missing in `Config` [1] but exists in
`NotTheRightConfig` [2]. [prop-missing]

config_HOC.js:13:1
13| y as NotTheRightConfig; // Error, configs don't match
config_HOC.js:10:1
10| x as NotTheRightConfig; // Error, configs don't match
^

References:
config_HOC.js:8:16
8| declare var y: React.Config<Props, DefaultProps>;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [1]
config_HOC.js:13:6
13| y as NotTheRightConfig; // Error, configs don't match
config_HOC.js:7:16
7| declare var x: Config;
^^^^^^ [1]
config_HOC.js:10:6
10| x as NotTheRightConfig; // Error, configs don't match
^^^^^^^^^^^^^^^^^ [2]


Error ----------------------------------------------------------------------------------------------- config_HOC.js:13:1
Error ----------------------------------------------------------------------------------------------- config_HOC.js:10:1

Cannot cast `y` to `NotTheRightConfig` because property `qux` is missing in `Props` [1] but exists in
Cannot cast `x` to `NotTheRightConfig` because property `qux` is missing in `Config` [1] but exists in
`NotTheRightConfig` [2]. [prop-missing]

config_HOC.js:13:1
13| y as NotTheRightConfig; // Error, configs don't match
config_HOC.js:10:1
10| x as NotTheRightConfig; // Error, configs don't match
^

References:
config_HOC.js:8:16
8| declare var y: React.Config<Props, DefaultProps>;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [1]
config_HOC.js:13:6
13| y as NotTheRightConfig; // Error, configs don't match
config_HOC.js:7:16
7| declare var x: Config;
^^^^^^ [1]
config_HOC.js:10:6
10| x as NotTheRightConfig; // Error, configs don't match
^^^^^^^^^^^^^^^^^ [2]


Error ----------------------------------------------------------------------------------------------- config_HOC.js:16:1

Cannot cast `z` to `React.Config` because property `bar` is missing in `NotTheRightConfig` [1] but exists in
`Props` [2]. [prop-missing]

config_HOC.js:16:1
16| z as React.Config<Props, DefaultProps>; // Error, configs don't match
^

References:
config_HOC.js:15:16
15| declare var z: NotTheRightConfig;
^^^^^^^^^^^^^^^^^ [1]
config_HOC.js:16:6
16| z as React.Config<Props, DefaultProps>; // Error, configs don't match
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2]


Error ----------------------------------------------------------------------------------------------- config_HOC.js:16:1

Cannot cast `z` to `React.Config` because property `foo` is missing in `NotTheRightConfig` [1] but exists in
`Props` [2]. [prop-missing]

config_HOC.js:16:1
16| z as React.Config<Props, DefaultProps>; // Error, configs don't match
^

References:
config_HOC.js:15:16
15| declare var z: NotTheRightConfig;
^^^^^^^^^^^^^^^^^ [1]
config_HOC.js:16:6
16| z as React.Config<Props, DefaultProps>; // Error, configs don't match
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2]


Error ---------------------------------------------------------------------------------------------- config_HOC.js:39:13
Error ---------------------------------------------------------------------------------------------- config_HOC.js:27:13

Cannot create `WrappedComponent` element because property `bar` is missing in props [1] but exists in object type [2].
[prop-missing]

config_HOC.js:39:13
39| const _c = <WrappedComponent foo={3} />; // Error missing bar
config_HOC.js:27:13
27| const _c = <WrappedComponent foo={3} />; // Error missing bar
^^^^^^^^^^^^^^^^

References:
config_HOC.js:39:12
39| const _c = <WrappedComponent foo={3} />; // Error missing bar
config_HOC.js:27:12
27| const _c = <WrappedComponent foo={3} />; // Error missing bar
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [1]
config_HOC.js:30:41
30| class Component extends React.Component<{foo: number, bar: number, ...}> {
config_HOC.js:18:41
18| class Component extends React.Component<{foo: number, bar: number, ...}> {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2]


Error ---------------------------------------------------------------------------------------------- config_HOC.js:44:13

Cannot create `WrappedComponent2` element because property `bar` is missing in props [1] but exists in object type [2].
[prop-missing]

config_HOC.js:44:13
44| const _f = <WrappedComponent2 />; // Error missing bar
^^^^^^^^^^^^^^^^^

References:
config_HOC.js:44:12
44| const _f = <WrappedComponent2 />; // Error missing bar
^^^^^^^^^^^^^^^^^^^^^ [1]
config_HOC.js:26:49
26| ): component(ref: React.RefSetter<Instance>, ...React.Config<Props, DefaultProps>) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2]


Error ------------------------------------------------------------------------------------------ create_element.js:15:13

Cannot create `C` element because property `bar` is missing in props [1] but exists in object type [2]. [prop-missing]
Expand Down Expand Up @@ -1198,7 +1144,7 @@ expression. [signature-verification-failure]



Found 63 errors
Found 60 errors

Only showing the most relevant union/intersection branches.
To see all branches, re-run Flow with --show-all-branches
19 changes: 1 addition & 18 deletions tests/component_type/config_HOC.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,16 @@ type DefaultProps = {foo: number, ...};
type Config = {+foo?: number, +bar: number, ...};

declare var x: Config;
declare var y: React.Config<Props, DefaultProps>;
x as React.Config<Props, DefaultProps>;
y as Config;

type NotTheRightConfig = {+baz: number, +qux: number, ...};
y as NotTheRightConfig; // Error, configs don't match

declare var z: NotTheRightConfig;
z as React.Config<Props, DefaultProps>; // Error, configs don't match
x as NotTheRightConfig; // Error, configs don't match

function HOC<Config: {...}, Instance>(
x: component(ref: React.RefSetter<Instance>, ...Config),
): component(ref: React.RefSetter<Instance>, ...Config) {
return x;
}

function HOC2<Props: {...}, DefaultProps: {...}, Instance>(
x: component(ref: React.RefSetter<Instance>, ...React.Config<Props, DefaultProps>),
): component(ref: React.RefSetter<Instance>, ...React.Config<Props, DefaultProps>) {
return x;
}

class Component extends React.Component<{foo: number, bar: number, ...}> {
static defaultProps: {foo: number, ...} = {foo: 3};
}
Expand All @@ -37,8 +25,3 @@ const WrappedComponent = HOC(Component);
const _a = <WrappedComponent foo={3} bar={3} />;
const _b = <WrappedComponent bar={3} />;
const _c = <WrappedComponent foo={3} />; // Error missing bar

const WrappedComponent2 = HOC2<{foo: number, bar: number, ...}, {foo: number, ...}, _>(
Component,
);
const _f = <WrappedComponent2 />; // Error missing bar
8 changes: 0 additions & 8 deletions tests/get_def2/get_def2.exp
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,3 @@ utilities.js:113:21
Flags:
utilities.js:3:33,3:35

utilities.js:119:12
Flags:
utilities.js:3:20,3:22

utilities.js:121:21
Flags:
utilities.js:3:33,3:35

8 changes: 0 additions & 8 deletions tests/get_def2/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,3 @@ f = () => {
<Comp foo={''} bar={3} />;
// ^
}

f = () => {
declare const Comp: React.ComponentType<React.Config<SourceObj, {bar: string}>>;
<Comp foo={''} bar={3} />;
// ^
<Comp foo={''} bar={3} />;
// ^
}
20 changes: 0 additions & 20 deletions tests/new_generics/config.js

This file was deleted.

97 changes: 4 additions & 93 deletions tests/new_generics/new_generics.exp
Original file line number Diff line number Diff line change
Expand Up @@ -428,95 +428,6 @@ References:
^^^^^^^^^^^^^^ [1]


Error --------------------------------------------------------------------------------------------------- config.js:16:3

Cannot cast `y` to `C` because `Props` [1] is incompatible with `C` [2]. [incompatible-cast]

config.js:16:3
16| y as C; // error, generics don't match
^

References:
config.js:11:6
11| y: React.Config<P, D>,
^^^^^^^^^^^^^^^^^^ [1]
config.js:16:8
16| y as C; // error, generics don't match
^ [2]


Error --------------------------------------------------------------------------------------------------- config.js:18:3

Cannot cast `y` to `NotTheRightConfig` because property `baz` is missing in `Props` [1] but exists in
`NotTheRightConfig` [2]. [prop-missing]

config.js:18:3
18| y as NotTheRightConfig; // Error, configs don't match
^

References:
config.js:11:6
11| y: React.Config<P, D>,
^^^^^^^^^^^^^^^^^^ [1]
config.js:18:8
18| y as NotTheRightConfig; // Error, configs don't match
^^^^^^^^^^^^^^^^^ [2]


Error --------------------------------------------------------------------------------------------------- config.js:18:3

Cannot cast `y` to `NotTheRightConfig` because property `qux` is missing in `Props` [1] but exists in
`NotTheRightConfig` [2]. [prop-missing]

config.js:18:3
18| y as NotTheRightConfig; // Error, configs don't match
^

References:
config.js:11:6
11| y: React.Config<P, D>,
^^^^^^^^^^^^^^^^^^ [1]
config.js:18:8
18| y as NotTheRightConfig; // Error, configs don't match
^^^^^^^^^^^^^^^^^ [2]


Error --------------------------------------------------------------------------------------------------- config.js:19:3

Cannot cast `z` to `React.Config` because property `bar` is missing in `NotTheRightConfig` [1] but exists in
`Props` [2]. [prop-missing]

config.js:19:3
19| z as React.Config<Props, DefaultProps>; // Error, configs don't match
^

References:
config.js:12:6
12| z: W,
^ [1]
config.js:19:8
19| z as React.Config<Props, DefaultProps>; // Error, configs don't match
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2]


Error --------------------------------------------------------------------------------------------------- config.js:19:3

Cannot cast `z` to `React.Config` because property `foo` is missing in `NotTheRightConfig` [1] but exists in
`Props` [2]. [prop-missing]

config.js:19:3
19| z as React.Config<Props, DefaultProps>; // Error, configs don't match
^

References:
config.js:12:6
12| z: W,
^ [1]
config.js:19:8
19| z as React.Config<Props, DefaultProps>; // Error, configs don't match
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2]


Error --------------------------------------------------------------------------------- detect_literal_subtypes.js:15:13

Invalid check of string literal `b` against string literal `a` [1] because string literal `b` [2] is incompatible with
Expand Down Expand Up @@ -1146,13 +1057,13 @@ References:
^^^^^ [3]


Error --------------------------------------------------------------------------------------------------- react.js:62:26
Error --------------------------------------------------------------------------------------------------- react.js:46:26

Cannot get `X.defaultProps` because property `defaultProps` is missing in `React.AbstractComponentStatics` [1].
[prop-missing]

react.js:62:26
62| C.defaultProps = {...X.defaultProps}; // nope
react.js:46:26
46| C.defaultProps = {...X.defaultProps}; // nope
^^^^^^^^^^^^

References:
Expand Down Expand Up @@ -1578,7 +1489,7 @@ References:



Found 92 errors
Found 87 errors

Only showing the most relevant union/intersection branches.
To see all branches, re-run Flow with --show-all-branches
16 changes: 0 additions & 16 deletions tests/new_generics/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ type DefaultProps = {|
b: string,
|};

function f<Config: Props>(
InputComponent: React.ComponentType<Config>,
): React.ComponentType<React.Config<Config, DefaultProps>> {
return class extends React.Component<React.Config<Config, DefaultProps>> {
f() {
const inputComponent = <InputComponent {...this.props} />;
}
};
}

function connect<TProps: {...}, SProps: TProps>(): React.ComponentType<SProps> {
return class extends React.Component<TProps> {};
}
Expand All @@ -44,12 +34,6 @@ function HOC<Config: {...}, Instance>(
return x;
}

function HOC2<Props: {...}, DefaultProps: {}, Instance>(
x: component(ref: React.RefSetter<Instance>, ...React.Config<Props, DefaultProps>),
): component(ref: React.RefSetter<Instance>, ...React.Config<Props, DefaultProps>) {
return x;
}

function WrapInDivWithExtraProp<Props: {...}, Instance>(
X: component(ref: React.RefSetter<Instance>, ...Props),
): component(...{|...$Exact<Props>, baz: number|}) {
Expand Down
Loading

0 comments on commit efe3518

Please sign in to comment.