Skip to content

Commit

Permalink
[flow][tests] Eliminate uses of React$MixedElement in tests
Browse files Browse the repository at this point in the history
Summary:
The final prep step of adding it to the banned internal-type list.

Changelog: [internal]

Reviewed By: gkz

Differential Revision: D67480744

fbshipit-source-id: 8413870b753bdcaf8c989511c5b658aef9281936
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Dec 19, 2024
1 parent 4598839 commit a04c6e2
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion tests/facebook_fbs_none/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
var React = require('react');
(<fbs />: React$MixedElement);
(<fbs />: React.MixedElement);
(<fbs />: number); // Error: ReactElement ~> number
2 changes: 1 addition & 1 deletion tests/facebook_fbt_none/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
var React = require('react');
(<fbt />: React$MixedElement);
(<fbt />: React.MixedElement);
(<fbt />: number); // Error: ReactElement ~> number
8 changes: 4 additions & 4 deletions tests/react_abstract_component/strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ const React = require('react');

declare var Component : React$ElementType;
const c = <Component f = {3}/>;
(c : React$MixedElement);
(c : React.MixedElement);

declare function foo(a: ?React$Component<any, any>): void;
declare var ref: ?React.ElementRef<React$ElementType>;
foo(ref);

class Component2 extends React.Component<{}> {};
const d = <Component2/>;
(d: React$MixedElement);
(d: React.MixedElement);

type Props = {someProp : string};
type State = {};

class MyComponent extends React.Component<Props, State> {
static _cloneElement(
element: ExactReactElement_DEPRECATED<typeof MyComponent>,
): React$MixedElement {
): React.MixedElement {
const someProp = 'some value';
return React.cloneElement(element, {someProp});
}
}


declare var e : ExactReactElement_DEPRECATED<Class<Component2>>;
(e : React$MixedElement);
(e : React.MixedElement);
2 changes: 1 addition & 1 deletion tests/react_jsx/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ const EnhancedClass_DefaultProps = hoc(Class_DefaultProps);
foo={1}
/>;

class ThisInJsxTag extends React.Component<{tag: () => React$MixedElement}> {
class ThisInJsxTag extends React.Component<{tag: () => React.MixedElement}> {
render(): React.Node {
return <this.props.tag />; // OK
}
Expand Down
20 changes: 10 additions & 10 deletions tests/render_types/render_types.exp
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ Cannot use `React.Element` [1] as the type argument of renders type. Only elemen
appear in renders but string [2] is not a component-syntax component. [invalid-render]

renders_to_renders.js:60:25
60| rendersFoo as renders React$MixedElement; // type checks, but invalid-render
60| rendersFoo as renders React.MixedElement; // type checks, but invalid-render
^^^^^^^^^^^^^^^^^^ [1]

References:
Expand All @@ -978,7 +978,7 @@ Cannot use `React.Element` [1] as the type argument of renders type. You can onl
when the third type argument is a render type and undefined [2] is not a render type. [invalid-render]

renders_to_renders.js:60:25
60| rendersFoo as renders React$MixedElement; // type checks, but invalid-render
60| rendersFoo as renders React.MixedElement; // type checks, but invalid-render
^^^^^^^^^^^^^^^^^^ [1]

References:
Expand All @@ -993,7 +993,7 @@ Cannot use `React.Element` [1] as the type argument of renders type. You can onl
when the third type argument is a render type and null [2] is not a render type. [invalid-render]

renders_to_renders.js:60:25
60| rendersFoo as renders React$MixedElement; // type checks, but invalid-render
60| rendersFoo as renders React.MixedElement; // type checks, but invalid-render
^^^^^^^^^^^^^^^^^^ [1]

References:
Expand All @@ -1008,7 +1008,7 @@ Cannot use `React.Element` [1] as the type argument of renders type. You can onl
when the third type argument is a render type and boolean [2] is not a render type. [invalid-render]

renders_to_renders.js:60:25
60| rendersFoo as renders React$MixedElement; // type checks, but invalid-render
60| rendersFoo as renders React.MixedElement; // type checks, but invalid-render
^^^^^^^^^^^^^^^^^^ [1]

References:
Expand All @@ -1023,7 +1023,7 @@ Cannot use `React.Element` [1] as the type argument of renders type. You can onl
when the third type argument is a render type and number [2] is not a render type. [invalid-render]

renders_to_renders.js:60:25
60| rendersFoo as renders React$MixedElement; // type checks, but invalid-render
60| rendersFoo as renders React.MixedElement; // type checks, but invalid-render
^^^^^^^^^^^^^^^^^^ [1]

References:
Expand All @@ -1038,7 +1038,7 @@ Cannot use `React.Element` [1] as the type argument of renders type. You can onl
when the third type argument is a render type and string [2] is not a render type. [invalid-render]

renders_to_renders.js:60:25
60| rendersFoo as renders React$MixedElement; // type checks, but invalid-render
60| rendersFoo as renders React.MixedElement; // type checks, but invalid-render
^^^^^^^^^^^^^^^^^^ [1]

References:
Expand All @@ -1053,7 +1053,7 @@ Cannot use `React.Element` [1] as the type argument of renders type. You can onl
when the third type argument is a render type and `React.Element` [2] is not a render type. [invalid-render]

renders_to_renders.js:60:25
60| rendersFoo as renders React$MixedElement; // type checks, but invalid-render
60| rendersFoo as renders React.MixedElement; // type checks, but invalid-render
^^^^^^^^^^^^^^^^^^ [1]

References:
Expand All @@ -1068,7 +1068,7 @@ Cannot use `React.Element` [1] as the type argument of renders type. You can onl
when the third type argument is a render type and `React.Portal` [2] is not a render type. [invalid-render]

renders_to_renders.js:60:25
60| rendersFoo as renders React$MixedElement; // type checks, but invalid-render
60| rendersFoo as renders React.MixedElement; // type checks, but invalid-render
^^^^^^^^^^^^^^^^^^ [1]

References:
Expand All @@ -1083,7 +1083,7 @@ Cannot use `React.Element` [1] as the type argument of renders type. You can onl
when the third type argument is a render type and `$Iterable` [2] is not a render type. [invalid-render]

renders_to_renders.js:60:25
60| rendersFoo as renders React$MixedElement; // type checks, but invalid-render
60| rendersFoo as renders React.MixedElement; // type checks, but invalid-render
^^^^^^^^^^^^^^^^^^ [1]

References:
Expand Down Expand Up @@ -1290,7 +1290,7 @@ Cannot cast `mixedElement` to renders union type because `React.Element` [1] doe

References:
renders_to_renders.js:105:31
105| declare const mixedElement: React$MixedElement;
105| declare const mixedElement: React.MixedElement;
^^^^^^^^^^^^^^^^^^ [1]
renders_to_renders.js:107:19
v--------
Expand Down
10 changes: 5 additions & 5 deletions tests/render_types/renders_to_renders.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ declare const rendersBazOrBaz: renders (
| null // invalid-render
| Bar
); // OK
rendersFoo as renders React$MixedElement; // type checks, but invalid-render
rendersFoo as renders React.MixedElement; // type checks, but invalid-render
rendersQux as renders (Foo | Bar); // OK
rendersQux as renders (Foo | Baz); // ERROR
component A0() renders null { // invalid-render
Expand Down Expand Up @@ -102,7 +102,7 @@ declare const rendersBazOrBaz: renders (
3 as renders (null | number); // type checks, but invalid-render
declare const x: ExactReactElement_DEPRECATED<() => React$Node>;
x as renders typeof x; // type checks, but invalid-render
declare const mixedElement: React$MixedElement;
declare const mixedElement: React.MixedElement;
// The test below ensures repositioning does not hit unsoundness in speculation
mixedElement as renders (
| Foo
Expand All @@ -114,11 +114,11 @@ declare const rendersBazOrBaz: renders (

/* Exit Structural Render Types */
{
rendersFooOrBar as React$MixedElement; // OK
rendersFooOrBar as React.MixedElement; // OK
rendersFooOrBar as empty; // ERROR
rendersFooOrBar as React$Node; // OK
rendersFooOrBar as React$Node; // OK
rendersNode as React$MixedElement; // invalid-render of rendersNode makes LHS any
rendersNode as React.MixedElement; // invalid-render of rendersNode makes LHS any
rendersNode as React$Node; // OK
declare const rendersNullOrNull: renders (null | null); // invalid-render
rendersNullOrNull as null; // invalid-render of rendersNullOrNull makes LHS any
Expand All @@ -128,7 +128,7 @@ declare const rendersBazOrBaz: renders (

/* Exit Nominal Render Types */
{
rendersBaz as React$MixedElement; // OK
rendersBaz as React.MixedElement; // OK
rendersBaz as empty; // ERROR
rendersBaz.props; // ERROR
}

0 comments on commit a04c6e2

Please sign in to comment.