Skip to content

Commit 2511213

Browse files
SamChou19815facebook-github-bot
authored andcommitted
Add annotations to fix future natural inference errors in xplat/js: 2/n
Reviewed By: andrewdacenko Differential Revision: D80266000 fbshipit-source-id: 3bcaa439cfc6f24de0c75f1c0f321b1924fe076a
1 parent 66d4927 commit 2511213

7 files changed

Lines changed: 25 additions & 18 deletions

File tree

packages/react-relay/ReactRelayPaginationContainer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,12 +750,12 @@ function createContainerWithFragments<
750750
}
751751

752752
_fetchPage(
753-
paginatingVariables: {
753+
paginatingVariables: $ReadOnly<{
754754
count: number,
755755
cursor: ?string,
756756
totalCount: number,
757757
...
758-
},
758+
}>,
759759
observer: Observer<void>,
760760
options: ?RefetchOptions,
761761
): Subscription {

packages/react-relay/ReactRelayQueryRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class ReactRelayQueryRenderer extends React.Component<Props, State> {
105105
// "leak" them before mounting (since we would be unable to clean up). For
106106
// that reason, we define them as null initially and fill them in after
107107
// mounting to avoid leaking memory.
108-
const retryCallbacks = {
108+
const retryCallbacks: RetryCallbacks = {
109109
handleDataChange: null,
110110
handleRetryAfterError: null,
111111
};

packages/react-relay/__tests__/ReactRelayTestMocker-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ describe('ReactRelayTestMocker', () => {
9999
});
100100

101101
it('updates properly via default values', () => {
102-
const testQueryDefault = {
102+
const testQueryDefault: NetworkWriteConfig = {
103103
query: ReactRelayTestMockerTestQuery,
104104
payload: {data: payload},
105105
};

packages/react-relay/relay-hooks/__tests__/useMutation-fast-refresh-test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
'use strict';
1313

14+
import type {useMutationFastRefreshTestCommentCreateMutation$variables} from './__generated__/useMutationFastRefreshTestCommentCreateMutation.graphql';
15+
1416
const RelayEnvironmentProvider = require('../RelayEnvironmentProvider');
1517
const useMutation = require('../useMutation');
1618
const React = require('react');
@@ -40,7 +42,7 @@ describe('useLazyLoadQueryNode', () => {
4042
},
4143
};
4244

43-
const variables = {
45+
const variables: useMutationFastRefreshTestCommentCreateMutation$variables = {
4446
input: {
4547
feedbackId: '<id>',
4648
},

packages/react-relay/relay-hooks/__tests__/usePreloadedQuery-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const preloadableConcreteRequest: PreloadableConcreteRequest<usePreloadedQueryTe
6262
params: query.params,
6363
};
6464

65-
const response = {
65+
const response: GraphQLResponse = {
6666
data: {
6767
node: {
6868
__typename: 'User',
@@ -75,7 +75,7 @@ const response = {
7575
},
7676
};
7777

78-
const responseRefetch = {
78+
const responseRefetch: GraphQLResponse = {
7979
data: {
8080
node: {
8181
__typename: 'User',

packages/relay-runtime/mutations/__tests__/commitMutation-test.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import type {GraphQLResponseWithoutData} from '../../network/RelayNetworkTypes';
1414
import type {Snapshot} from '../../store/RelayStoreTypes';
1515
import type {RecordSourceSelectorProxy} from '../../store/RelayStoreTypes';
1616
import type {DeclarativeMutationConfig} from '../RelayDeclarativeMutationConfig';
17+
import type {commitMutationTest1Mutation$variables} from './__generated__/commitMutationTest1Mutation.graphql';
18+
import type {commitMutationTest2Mutation$variables} from './__generated__/commitMutationTest2Mutation.graphql';
19+
import type {commitMutationTest3Mutation$variables} from './__generated__/commitMutationTest3Mutation.graphql';
1720
import type {
1821
commitMutationTest4Query$data,
1922
commitMutationTest4Query$variables,
@@ -63,7 +66,9 @@ describe('Configs: NODE_DELETE', () => {
6366
const feedbackID = 'feedback123';
6467
const firstCommentID = 'comment456';
6568
const secondCommentID = 'comment789';
66-
const variables = {
69+
const variables: commitMutationTest1Mutation$variables = {
70+
/* $FlowFixMe[prop-missing] error exposed when improving flow typing of
71+
* commitMutation */
6772
input: {
6873
deletedCommentId: firstCommentID,
6974
},
@@ -150,8 +155,6 @@ describe('Configs: NODE_DELETE', () => {
150155
optimisticResponse,
151156
optimisticUpdater,
152157
updater,
153-
/* $FlowFixMe[prop-missing] error exposed when improving flow typing of
154-
* commitMutation */
155158
variables,
156159
});
157160
expect(callback.mock.calls.length).toBe(1);
@@ -202,7 +205,7 @@ describe('Configs: RANGE_DELETE', () => {
202205
}
203206
`;
204207
const commentID = 'comment123';
205-
const variables = {
208+
const variables: commitMutationTest2Mutation$variables = {
206209
input: {
207210
commentId: commentID,
208211
},
@@ -353,7 +356,7 @@ describe('Configs: RANGE_DELETE', () => {
353356
pathToConnection: ['actor', 'friends'],
354357
},
355358
];
356-
const variables = {
359+
const variables: commitMutationTest3Mutation$variables = {
357360
input: {
358361
friendId: '456',
359362
},

packages/relay-runtime/subscription/__tests__/requestSubscription-test.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import type {GraphQLResponse} from '../../network/RelayNetworkTypes';
1515
import type {RecordSourceSelectorProxy} from '../../store/RelayStoreTypes';
1616
import type {RequestParameters} from '../../util/RelayConcreteNode';
1717
import type {CacheConfig, Variables} from '../../util/RelayRuntimeTypes';
18+
import type {requestSubscriptionTest1CommentCreateSubscription$variables} from './__generated__/requestSubscriptionTest1CommentCreateSubscription.graphql';
1819

1920
const RelayNetwork = require('../../network/RelayNetwork');
2021
const RelayObservable = require('../../network/RelayObservable');
@@ -203,12 +204,13 @@ describe('requestSubscription-test', () => {
203204
const metadata = {
204205
text: 'Gave Relay',
205206
};
206-
const variables = {
207-
input: {
208-
feedbackId,
209-
text: secondCommentBody,
210-
},
211-
};
207+
const variables: requestSubscriptionTest1CommentCreateSubscription$variables =
208+
{
209+
input: {
210+
feedbackId,
211+
text: secondCommentBody,
212+
},
213+
};
212214

213215
beforeEach(() => {
214216
CommentCreateSubscription = graphql`

0 commit comments

Comments
 (0)