Skip to content

Commit

Permalink
codemod away flow exact object type syntax (#3981)
Browse files Browse the repository at this point in the history
Summary:
Don't need these anymore after #3980

Pull Request resolved: #3981

Test Plan:
Imported from GitHub, without a `Test Plan:` line.

**Static Docs Preview: relay**
|[Full Site](https://our.intern.facebook.com/intern/staticdocs/eph/D37248900/V2/relay/)|

|**Modified Pages**|

Reviewed By: alunyov

Differential Revision: D37248900

Pulled By: voideanvalue

fbshipit-source-id: 43359cd883850f6b100638bb1480719367911e0b
  • Loading branch information
voideanvalue authored and facebook-github-bot committed Jun 21, 2022
1 parent b88a3c9 commit bd2e417
Show file tree
Hide file tree
Showing 352 changed files with 885 additions and 1,571 deletions.
4 changes: 2 additions & 2 deletions packages/babel-plugin-relay/compileGraphQLTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function createNode(
state: BabelState,
path: $FlowFixMe,
graphqlDefinition: OperationDefinitionNode | FragmentDefinitionNode,
options: {|
options: {
// If an output directory is specified when running relay-compiler this should point to that directory
artifactDirectory: ?string,
// Generate eager es modules instead of lazy require
Expand All @@ -99,7 +99,7 @@ function createNode(
isDevVariable: ?string,
// Use haste style global requires, defaults to false.
isHasteMode: boolean,
|},
},
): Object {
const definitionName = graphqlDefinition.name && graphqlDefinition.name.value;
if (!definitionName) {
Expand Down
2 changes: 0 additions & 2 deletions packages/react-relay/ReactRelayContainerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';

function getComponentName(component: React$ComponentType<any>): string {
Expand Down
2 changes: 0 additions & 2 deletions packages/react-relay/ReactRelayContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';
import type {RelayContext} from 'relay-runtime/store/RelayStoreTypes';

Expand Down
2 changes: 0 additions & 2 deletions packages/react-relay/ReactRelayFragmentContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';
import type {GeneratedNodeMap, RelayProp, $RelayProps} from './ReactRelayTypes';
import type {
Expand Down
2 changes: 0 additions & 2 deletions packages/react-relay/ReactRelayFragmentMockRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';

const ReactRelayContext = require('./ReactRelayContext');
Expand Down
2 changes: 0 additions & 2 deletions packages/react-relay/ReactRelayLocalQueryRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';

import type {ReactRelayQueryRendererContext as ReactRelayQueryRendererContextType} from './ReactRelayQueryRendererContext';
Expand Down
2 changes: 0 additions & 2 deletions packages/react-relay/ReactRelayPaginationContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';

import type {
Expand Down
18 changes: 8 additions & 10 deletions packages/react-relay/ReactRelayQueryFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';

import type {
Expand All @@ -35,26 +33,26 @@ type OnDataChange = ({
}) => void;

/** The external API of 'fetch' **/
export type FetchOptions = {|
export type FetchOptions = {
environment: IEnvironment,
onDataChange?: null | OnDataChange,
operation: OperationDescriptor,
|};
};

// Internally we keep an array of onDataChange callbacks, to support reusing
// the queryRenderer for multiple components.
type FetchOptionsInternal = {|
type FetchOptionsInternal = {
environment: IEnvironment,
onDataChangeCallbacks: Array<OnDataChange>,
operation: OperationDescriptor,
|};
};

export type ExecuteConfig = {|
export type ExecuteConfig = {
environment: IEnvironment,
operation: OperationDescriptor,
// Allows pagination container to retain results from previous queries
preservePreviousReferences?: boolean,
|};
};

class ReactRelayQueryFetcher {
_fetchOptions: ?FetchOptionsInternal;
Expand All @@ -77,10 +75,10 @@ class ReactRelayQueryFetcher {
}
}

getSelectionReferences(): {|
getSelectionReferences(): {
cacheSelectionReference: ?Disposable,
selectionReferences: Array<Disposable>,
|} {
} {
return {
cacheSelectionReference: this._cacheSelectionReference,
selectionReferences: this._selectionReferences,
Expand Down
22 changes: 10 additions & 12 deletions packages/react-relay/ReactRelayQueryRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';

import type {ReactRelayQueryRendererContext as ReactRelayQueryRendererContextType} from './ReactRelayQueryRendererContext';
Expand All @@ -34,7 +32,7 @@ const {
getRequest,
} = require('relay-runtime');

type RetryCallbacks = {|
type RetryCallbacks = {
handleDataChange:
| null
| (({
Expand All @@ -43,39 +41,39 @@ type RetryCallbacks = {|
...
}) => void),
handleRetryAfterError: null | ((error: Error) => void),
|};
};

export type RenderProps<T> = {|
export type RenderProps<T> = {
error: ?Error,
props: ?T,
retry: ?(cacheConfigOverride?: CacheConfig) => void,
|};
};
/**
* React may double-fire the constructor, and we call 'fetch' in the
* constructor. If a request is already in flight from a previous call to the
* constructor, just reuse the query fetcher and wait for the response.
*/
const requestCache: {
[string]: void | {|
[string]: void | {
queryFetcher: ReactRelayQueryFetcher,
snapshot: ?Snapshot,
|},
},
} = {};

const queryRendererContext: ReactRelayQueryRendererContextType = {
rootIsQueryRenderer: true,
};

export type Props = {|
export type Props = {
cacheConfig?: ?CacheConfig,
fetchPolicy?: 'store-and-network' | 'network-only',
environment: IEnvironment,
query: ?GraphQLTaggedNode,
render: (renderProps: RenderProps<Object>) => React.Node,
variables: Variables,
|};
};

type State = {|
type State = {
error: Error | null,
prevPropsEnvironment: IEnvironment,
prevPropsVariables: Variables,
Expand All @@ -86,7 +84,7 @@ type State = {|
retryCallbacks: RetryCallbacks,
requestCacheKey: ?string,
snapshot: Snapshot | null,
|};
};

/**
* @public
Expand Down
4 changes: 1 addition & 3 deletions packages/react-relay/ReactRelayQueryRendererContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';
const React = require('react');

export type ReactRelayQueryRendererContext = {|rootIsQueryRenderer: boolean|};
export type ReactRelayQueryRendererContext = {rootIsQueryRenderer: boolean};

module.exports = (React.createContext({
rootIsQueryRenderer: false,
Expand Down
2 changes: 0 additions & 2 deletions packages/react-relay/ReactRelayRefetchContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';

import type {
Expand Down
2 changes: 0 additions & 2 deletions packages/react-relay/ReactRelayTestMocker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';

import type {
Expand Down
14 changes: 6 additions & 8 deletions packages/react-relay/ReactRelayTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';

import type {
Expand All @@ -29,7 +27,7 @@ export type ObserverOrCallback = Observer<void> | ((error: ?Error) => mixed);
// RelayRefetchProp to flow into a RelayProp.
export type RelayProp = {+environment: IEnvironment, ...};

export type RelayPaginationProp = {|
export type RelayPaginationProp = {
+environment: IEnvironment,
+hasMore: () => boolean,
+isLoading: () => boolean,
Expand All @@ -43,23 +41,23 @@ export type RelayPaginationProp = {|
observerOrCallback: ?ObserverOrCallback,
refetchVariables: ?Variables,
) => ?Disposable,
|};
};

export type RelayRefetchProp = {|
export type RelayRefetchProp = {
+environment: IEnvironment,
+refetch: (
refetchVariables: Variables | ((fragmentVariables: Variables) => Variables),
renderVariables: ?Variables,
observerOrCallback: ?ObserverOrCallback,
options?: RefetchOptions,
) => Disposable,
|};
};

export type RefetchOptions = {|
export type RefetchOptions = {
+force?: boolean,
+fetchPolicy?: 'store-or-network' | 'network-only',
+metadata?: {[key: string]: mixed, ...},
|};
};

/**
* A utility type which takes the type of a fragment's data (typically found in
Expand Down
2 changes: 0 additions & 2 deletions packages/react-relay/RelayContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';

import type {RelayContext} from 'relay-runtime';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';

const {
Expand Down Expand Up @@ -127,7 +125,7 @@ module.exports = {
return <Bar {...props} />;
},
checkStaticsAndMethodsProxying(): React.Node {
class ProxyChecker extends React.PureComponent<{||}> {
class ProxyChecker extends React.PureComponent<{}> {
_barRef: ?BarComponent;
getString(): string {
const ok = this._barRef ? this._barRef.getNum() : 'default'; // legit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';

const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';

const {
Expand Down
6 changes: 2 additions & 4 deletions packages/react-relay/__flowtests__/RelayModern-flowtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';

import type {$FragmentRef} from '../ReactRelayTypes';
Expand Down Expand Up @@ -252,9 +250,9 @@ declare var aComplexUserRef: {
optionalUsers={null}
/>;

class AnyTest extends React.Component<{|
class AnyTest extends React.Component<{
anything: any,
|}> {}
}> {}
const AnyTestContainer = createFragmentContainer(AnyTest, {});

<AnyTestContainer anything={42} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';

import type {RelayModernFlowtest_user$ref} from './RelayModernFlowtest_user.graphql';
import type {FragmentType} from 'relay-runtime';

declare export opaque type RelayModernFlowtest_badref$ref: FragmentType;
export type RelayModernFlowtest_badref = {|
export type RelayModernFlowtest_badref = {
+id: string,
+$fragmentSpreads: RelayModernFlowtest_user$ref,
+$fragmentType: RelayModernFlowtest_badref$ref,
|};
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
* @format
*/

// flowlint ambiguous-object-type:error

'use strict';

import type {RelayModernFlowtest_user$ref} from './RelayModernFlowtest_user.graphql';
import type {FragmentType} from 'relay-runtime';

declare export opaque type RelayModernFlowtest_notref$ref: FragmentType;
export type RelayModernFlowtest_notref = {|
export type RelayModernFlowtest_notref = {
+id: string,
+$fragmentSpreads: RelayModernFlowtest_user$ref,
+$fragmentType: RelayModernFlowtest_notref$ref,
|};
};

0 comments on commit bd2e417

Please sign in to comment.