Skip to content

Commit

Permalink
Implicit instantiation codemod
Browse files Browse the repository at this point in the history
Reviewed By: SamChou19815

Differential Revision: D40413074

fbshipit-source-id: 42b52719978f1098169662b503dbcfd8cefdad53
  • Loading branch information
jbrown215 authored and facebook-github-bot committed Oct 19, 2022
1 parent 8dc927f commit f96771b
Show file tree
Hide file tree
Showing 39 changed files with 109 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ type Props = $ReadOnly<{

function ActorMessage(props: Props) {
const data = useFragment(fragment, props.myFragment);
const [commit] = useMutation(mutation);
const [commit] = useMutation<$FlowFixMe>(mutation);

// We're calling this hook only to verify that it won't throw.
// `useRelayActorEnvironment` should be able to have access to `getEnvironmentForActor` function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ describe('FragmentResource Client Edges behavior', () => {
// Use our own simulation of setTimeout due to bugs in Jest's.
// We can't mock SuspenseResource's setTimeout using Jest mocks because
// they aren't imported from a module, so we swizzle the global one.
const timeouts = new Map();
const timeouts = new Map<number, $FlowFixMe>();
let nextTimeoutID = 0;
const originalSetTimeout = global.setTimeout;
const originalClearTimeout = global.clearTimeout;
Expand Down
36 changes: 18 additions & 18 deletions packages/react-relay/relay-hooks/__tests__/QueryResource-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ describe('QueryResource', () => {
let thrown = false;
let sink;
const networkExecute = jest.fn();
const errorFetchObservable = Observable.create(s => {
const errorFetchObservable = Observable.create<$FlowFixMe>(s => {
networkExecute();
sink = s;
});
Expand Down Expand Up @@ -331,7 +331,7 @@ describe('QueryResource', () => {
});

const networkExecute = jest.fn();
const syncFetchObservable = Observable.create(sink => {
const syncFetchObservable = Observable.create<$FlowFixMe>(sink => {
environment.commitPayload(queryMissingData, {
node: {
__typename: 'User',
Expand Down Expand Up @@ -375,7 +375,7 @@ describe('QueryResource', () => {
it('should throw error if network request errors synchronously', () => {
let thrown = false;
const networkExecute = jest.fn();
const errorFetchObservable = Observable.create(sink => {
const errorFetchObservable = Observable.create<$FlowFixMe>(sink => {
networkExecute();
sink.error(new Error('Oops'));
});
Expand Down Expand Up @@ -702,7 +702,7 @@ describe('QueryResource', () => {
let thrown = false;
let sink;
const networkExecute = jest.fn();
const errorFetchObservable = Observable.create(s => {
const errorFetchObservable = Observable.create<$FlowFixMe>(s => {
networkExecute();
sink = s;
});
Expand Down Expand Up @@ -753,7 +753,7 @@ describe('QueryResource', () => {
});

const networkExecute = jest.fn();
const syncFetchObservable = Observable.create(sink => {
const syncFetchObservable = Observable.create<$FlowFixMe>(sink => {
environment.commitPayload(queryMissingData, {
node: {
__typename: 'User',
Expand Down Expand Up @@ -797,7 +797,7 @@ describe('QueryResource', () => {
it('should throw error if network request errors synchronously', () => {
let thrown = false;
const networkExecute = jest.fn();
const errorFetchObservable = Observable.create(sink => {
const errorFetchObservable = Observable.create<$FlowFixMe>(sink => {
networkExecute();
sink.error(new Error('Oops'));
});
Expand Down Expand Up @@ -1262,7 +1262,7 @@ describe('QueryResource', () => {
let thrown = false;
let sink;
const networkExecute = jest.fn();
const errorFetchObservable = Observable.create(s => {
const errorFetchObservable = Observable.create<$FlowFixMe>(s => {
networkExecute();
sink = s;
});
Expand Down Expand Up @@ -1306,7 +1306,7 @@ describe('QueryResource', () => {
});

const networkExecute = jest.fn();
const syncFetchObservable = Observable.create(sink => {
const syncFetchObservable = Observable.create<$FlowFixMe>(sink => {
environment.commitPayload(queryMissingData, {
node: {
__typename: 'User',
Expand Down Expand Up @@ -1350,7 +1350,7 @@ describe('QueryResource', () => {
it('should throw error if network request errors synchronously', () => {
let thrown = false;
const networkExecute = jest.fn();
const errorFetchObservable = Observable.create(sink => {
const errorFetchObservable = Observable.create<$FlowFixMe>(sink => {
networkExecute();
sink.error(new Error('Oops'));
});
Expand Down Expand Up @@ -1500,7 +1500,7 @@ describe('QueryResource', () => {
let thrown = false;
let sink;
const networkExecute = jest.fn();
const errorFetchObservable = Observable.create(s => {
const errorFetchObservable = Observable.create<$FlowFixMe>(s => {
networkExecute();
sink = s;
});
Expand Down Expand Up @@ -1549,7 +1549,7 @@ describe('QueryResource', () => {
});

const networkExecute = jest.fn();
const syncFetchObservable = Observable.create(sink => {
const syncFetchObservable = Observable.create<$FlowFixMe>(sink => {
environment.commitPayload(queryMissingData, {
node: {
__typename: 'User',
Expand Down Expand Up @@ -1593,7 +1593,7 @@ describe('QueryResource', () => {
it('should throw error if network request errors synchronously', () => {
let thrown = false;
const networkExecute = jest.fn();
const errorFetchObservable = Observable.create(sink => {
const errorFetchObservable = Observable.create<$FlowFixMe>(sink => {
networkExecute();
sink.error(new Error('Oops'));
});
Expand Down Expand Up @@ -1725,7 +1725,7 @@ describe('QueryResource', () => {
let thrownError = false;
let sink;
const networkExecute = jest.fn();
const errorFetchObservable = Observable.create(s => {
const errorFetchObservable = Observable.create<$FlowFixMe>(s => {
networkExecute();
sink = s;
});
Expand Down Expand Up @@ -1772,7 +1772,7 @@ describe('QueryResource', () => {

it('should return result if network observable returns synchronously', () => {
const networkExecute = jest.fn();
const syncFetchObservable = Observable.create(sink => {
const syncFetchObservable = Observable.create<$FlowFixMe>(sink => {
const snapshot = environment.lookup(query.fragment);
networkExecute();
sink.next((snapshot: $FlowFixMe));
Expand Down Expand Up @@ -1810,7 +1810,7 @@ describe('QueryResource', () => {
it('should throw error if network request errors synchronously', () => {
let thrown = false;
const networkExecute = jest.fn();
const errorFetchObservable = Observable.create(sink => {
const errorFetchObservable = Observable.create<$FlowFixMe>(sink => {
networkExecute();
const error = new Error('Oops');
sink.error(error);
Expand Down Expand Up @@ -1907,7 +1907,7 @@ describe('QueryResource', () => {
let thrownError = false;
let sink;
const networkExecute = jest.fn();
const errorFetchObservable = Observable.create(s => {
const errorFetchObservable = Observable.create<$FlowFixMe>(s => {
networkExecute();
sink = s;
});
Expand Down Expand Up @@ -1954,7 +1954,7 @@ describe('QueryResource', () => {

it('should return result if network observable returns synchronously', () => {
const networkExecute = jest.fn();
const syncFetchObservable = Observable.create(sink => {
const syncFetchObservable = Observable.create<$FlowFixMe>(sink => {
const snapshot = environment.lookup(query.fragment);
networkExecute();
sink.next((snapshot: $FlowFixMe));
Expand Down Expand Up @@ -1992,7 +1992,7 @@ describe('QueryResource', () => {
it('should throw error if network request errors synchronously', () => {
let thrown = false;
const networkExecute = jest.fn();
const errorFetchObservable = Observable.create(sink => {
const errorFetchObservable = Observable.create<$FlowFixMe>(sink => {
networkExecute();
const error = new Error('Oops');
sink.error(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('useBlockingPaginationFragment', () => {
fragmentRef: mixed,
) {
// $FlowFixMe[incompatible-call]
const {data, ...result} = useBlockingPaginationFragmentOriginal(
const {data, ...result} = useBlockingPaginationFragmentOriginal<any, mixed>(
fragmentNode,
// $FlowFixMe[incompatible-call]
// $FlowFixMe[prop-missing]
Expand Down Expand Up @@ -1655,7 +1655,7 @@ describe('useBlockingPaginationFragment', () => {
const useLoadMoreFunction = require('../useLoadMoreFunction');
// $FlowFixMe[prop-missing]
useLoadMoreFunction.mockImplementation((...args) =>
jest.requireActual('../useLoadMoreFunction')(...args),
jest.requireActual<any>('../useLoadMoreFunction')(...args),
);

const callback = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('useBlockingPaginationFragment with useTransition', () => {
) {
const [isPendingNext, startTransition] = useTransition();
// $FlowFixMe[incompatible-call]
const {data, ...result} = useBlockingPaginationFragmentOriginal(
const {data, ...result} = useBlockingPaginationFragmentOriginal<any, any>(
fragmentNode,
// $FlowFixMe[prop-missing]
// $FlowFixMe[incompatible-call]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ beforeEach(() => {
}) {
renderCount = (renderCount || 0) + 1;
[loadedEntryPoint, entryPointLoaderCallback, disposeEntryPoint] =
useEntryPointLoader(environmentProvider, entryPoint);
useEntryPointLoader<{...}, any, any, any, any, any, any>(
environmentProvider,
entryPoint,
);
return null;
};
loadEntryPoint.mockClear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe.skip('useFragmentNode-react-double-effects-test', () => {

let renderLogs = [];
const FragmentComponent = ({user}: $TEMPORARY$object<{user: mixed}>) => {
const {data} = useFragmentNode(gqlFragment, user, 'TestComponent');
const {data} = useFragmentNode<any>(gqlFragment, user, 'TestComponent');
useEffect(() => {
renderLogs.push(`commit: ${data.name}`);
return () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function useFragmentNode(
__isWithinUnmatchedTypeRefinement: boolean,
}>,
) {
const result = useFragmentNodeOriginal(
const result = useFragmentNodeOriginal<any>(
fragmentNode,
fragmentRef,
'TestDisplayName',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe.each([
>,
fragmentRef: any,
) {
const result = useFragmentNodeOriginal(
const result = useFragmentNodeOriginal<any>(
fragmentNode,
fragmentRef,
'TestDisplayName',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ describe('useLazyLoadQueryNode', () => {
ReactRefreshRuntime.injectIntoGlobalHook(global);
let commit;
const V1 = function (props: {}) {
const [commitFn, isMutationInFlight] = useMutation(CommentCreateMutation);
const [commitFn, isMutationInFlight] = useMutation<any>(
CommentCreateMutation,
);
commit = commitFn;
return isInFlightFn(isMutationInFlight);
};
Expand Down Expand Up @@ -116,7 +118,9 @@ describe('useLazyLoadQueryNode', () => {

// Trigger a fast fresh
function V2(props: any) {
const [commitFn, isMutationInFlight] = useMutation(CommentCreateMutation);
const [commitFn, isMutationInFlight] = useMutation<any>(
CommentCreateMutation,
);
commit = commitFn;
return isInFlightFn(isMutationInFlight);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ beforeEach(() => {
}) {
const [mutation, setMutationFn] = useState(initialMutation);
setMutation = setMutationFn;
const [commitFn, isMutationInFlight] = useMutation(mutation);
const [commitFn, isMutationInFlight] = useMutation<any>(mutation);
commit = (config: any) =>
ReactTestRenderer.act(() => {
disposable = commitFn(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe.each([
}

function usePaginationFragment(fragmentNode: any, fragmentRef: any) {
const {data, ...result} = usePaginationFragmentOriginal(
const {data, ...result} = usePaginationFragmentOriginal<any, any>(
fragmentNode,
fragmentRef,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('useRefetchableFragment', () => {
let Renderer;

function useRefetchableFragment(fragmentNode: any, fragmentRef: any) {
const [data, refetch] = useRefetchableFragmentOriginal(
const [data, refetch] = useRefetchableFragmentOriginal<any, any>(
fragmentNode,
// $FlowFixMe[incompatible-call]
// $FlowFixMe[prop-missing]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ describe.each([
}

function useRefetchableFragmentNode(fragmentNode: any, fragmentRef: any) {
const result = useRefetchableFragmentNodeOriginal(
const result = useRefetchableFragmentNodeOriginal<any, any>(
fragmentNode,
fragmentRef,
'TestDisplayName',
Expand Down Expand Up @@ -3074,7 +3074,7 @@ describe.each([
describe('disposing', () => {
const unsubscribe = jest.fn();
jest.doMock('relay-runtime', () => {
const originalRuntime = jest.requireActual('relay-runtime');
const originalRuntime = jest.requireActual<any>('relay-runtime');
const originalInternal = originalRuntime.__internal;
return {
...originalRuntime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('useRefetchableFragmentNode with useTransition', () => {
) {
const [isPending, startTransition] = useTransition();
const {fragmentData: data, ...result} =
useRefetchableFragmentNodeOriginal(
useRefetchableFragmentNodeOriginal<any, any>(
fragmentNode,
fragmentRef,
'TestComponent',
Expand Down
2 changes: 1 addition & 1 deletion packages/react-relay/relay-hooks/loadQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function loadQuery<
// of the operation, and then replay them to the Observable we
// ultimately return.
const executionSubject = new ReplaySubject();
const returnedObservable = Observable.create(sink =>
const returnedObservable = Observable.create<GraphQLResponse>(sink =>
executionSubject.subscribe(sink),
);

Expand Down
4 changes: 2 additions & 2 deletions packages/react-relay/relay-hooks/preloadQuery_DEPRECATED.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const WEAKMAP_SUPPORTED = typeof WeakMap === 'function';
const STORE_OR_NETWORK_DEFAULT: PreloadFetchPolicy = 'store-or-network';

const pendingQueriesByEnvironment = WEAKMAP_SUPPORTED
? new WeakMap()
? new WeakMap<IEnvironment, Map<string, PendingQueryEntry>>()
: new Map();

type PendingQueryEntry =
Expand Down Expand Up @@ -91,7 +91,7 @@ function preloadQuery<TQuery: OperationType, TEnvironmentProviderOptions>(
);
const source =
queryEntry.kind === 'network'
? Observable.create(sink => {
? Observable.create<GraphQLResponse>(sink => {
let subscription;
if (pendingQueries.get(queryEntry.cacheKey) == null) {
const newQueryEntry = preloadQueryDeduped(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ describe('useLazyLoadQuery_REACT_CACHE', () => {
responseIsRejected &&
(shouldAwaitFetchResult || responseIsSynchronous);

const thrownPromises = new Set();
const thrownPromises = new Set<any>();
let numberOfRendersObserved = 0;
function TestComponent({output}: {output: boolean}) {
numberOfRendersObserved++;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-relay/relay-hooks/useLazyLoadQueryNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function useLazyLoadQueryNode<TQuery: OperationType>({
});

const {fragmentNode, fragmentRef} = preparedQueryResult;
const {data} = useFragmentNode(
const {data} = useFragmentNode<$FlowFixMe>(
fragmentNode,
fragmentRef,
componentDisplayName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function update(store: RecordSourceProxy, payload: HandleFieldPayload): void {
clientPageInfo &&
args.after === clientPageInfo.getValue(END_CURSOR)
) {
const nodeIDs = new Set();
const nodeIDs = new Set<mixed>();
mergeEdges(prevEdges, nextEdges, nodeIDs);
mergeEdges(serverEdges, nextEdges, nodeIDs);
} else {
Expand All @@ -168,7 +168,7 @@ function update(store: RecordSourceProxy, payload: HandleFieldPayload): void {
clientPageInfo &&
args.before === clientPageInfo.getValue(START_CURSOR)
) {
const nodeIDs = new Set();
const nodeIDs = new Set<mixed>();
mergeEdges(serverEdges, nextEdges, nodeIDs);
mergeEdges(prevEdges, nextEdges, nodeIDs);
} else {
Expand Down
Loading

0 comments on commit f96771b

Please sign in to comment.