fix: remove deprecated existential Flow type and use any for now (#77)

<!-- Please provide enough information so that others can review your pull request. -->
<!-- Keep pull requests small and focused on a single change. -->

### Summary

Existential type (`*`) is long deprecated, let's just use `any` for now.

### Test plan

Added some more Flow typings to `shallow.test.js` that were failing because of existential type.
This commit is contained in:
Michał Pierzchała
2018-11-28 12:49:15 +01:00
committed by GitHub
parent 6dfbc6794b
commit c5910d94e4
7 changed files with 23 additions and 14 deletions
@@ -13,7 +13,9 @@ exports[`shallow rendering React Test Instance 1`] = `
`;
exports[`shallow rendering React elements 1`] = `
<View>
<View
testID="2"
>
<Text
testID="text-button"
>
+7 -3
View File
@@ -3,14 +3,18 @@ import React from 'react';
import { View, Text } from 'react-native';
import { shallow, render } from '..';
const TextPress = () => (
<View>
type Props = {|
+dummyID?: string,
|};
const TextPress = ({ dummyID }: Props) => (
<View testID={dummyID}>
<Text testID="text-button">Press me</Text>
</View>
);
test('shallow rendering React elements', () => {
const { output } = shallow(<TextPress />);
const { output } = shallow(<TextPress dummyID="2" />);
expect(output).toMatchSnapshot();
});
+6 -3
View File
@@ -10,11 +10,11 @@ import format from './helpers/format';
* Log pretty-printed deep test component instance
*/
function debugDeepElementOrInstance(
instance: React.Element<*> | ?ReactTestRendererJSON,
instance: React.Element<any> | ?ReactTestRendererJSON,
message?: any = ''
) {
try {
// We're assuming React.Element<*> here and fallback to
// We're assuming React.Element<any> here and fallback to
// rendering ?ReactTestRendererJSON
// $FlowFixMe
const { toJSON } = render(instance);
@@ -29,7 +29,10 @@ function debugDeepElementOrInstance(
}
}
function debug(instance: ReactTestInstance | React.Element<*>, message?: any) {
function debug(
instance: ReactTestInstance | React.Element<any>,
message?: any
) {
return debugShallow(instance, message);
}
+1 -1
View File
@@ -7,7 +7,7 @@ import format from './format';
* Log pretty-printed shallow test component instance
*/
export default function debugShallow(
instance: ReactTestInstance | React.Element<*>,
instance: ReactTestInstance | React.Element<any>,
message?: any
) {
const { output } = shallow(instance);
+2 -2
View File
@@ -11,8 +11,8 @@ import debugDeep from './helpers/debugDeep';
* to assert on the output.
*/
export default function render(
component: React.Element<*>,
options?: { createNodeMock: (element: React.Element<*>) => any }
component: React.Element<any>,
options?: { createNodeMock: (element: React.Element<any>) => any }
) {
const renderer = TestRenderer.create(component, options);
const instance = renderer.root;
+1 -1
View File
@@ -6,7 +6,7 @@ import ShallowRenderer from 'react-test-renderer/shallow'; // eslint-disable-lin
* Renders test component shallowly using react-test-renderer/shallow
*/
export default function shallow(
instance: ReactTestInstance | React.Element<*>
instance: ReactTestInstance | React.Element<any>
) {
const renderer = new ShallowRenderer();