react-relay 20.1.1 → 21.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ReactRelayContext.js +1 -1
- package/ReactRelayContext.js.flow +2 -2
- package/ReactRelayFragmentContainer.js.flow +8 -9
- package/ReactRelayLocalQueryRenderer.js.flow +11 -3
- package/ReactRelayLoggingContext.js.flow +3 -3
- package/ReactRelayPaginationContainer.js.flow +32 -25
- package/ReactRelayQueryFetcher.js.flow +1 -1
- package/ReactRelayQueryRenderer.js.flow +2 -2
- package/ReactRelayQueryRendererContext.js.flow +2 -2
- package/ReactRelayRefetchContainer.js.flow +17 -14
- package/ReactRelayTestMocker.js.flow +10 -10
- package/ReactRelayTypes.d.ts +377 -0
- package/ReactRelayTypes.js.flow +47 -43
- package/RelayContext.js.flow +3 -3
- package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +11 -11
- package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +5 -5
- package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +5 -5
- package/__flowtests__/RelayModern-flowtest.js.flow +32 -32
- package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +1 -1
- package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +3 -4
- package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +3 -4
- package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +9 -10
- package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +4 -5
- package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +9 -10
- package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +4 -5
- package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +3 -4
- package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +3 -4
- package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +3 -4
- package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +5 -6
- package/buildReactRelayContainer.js.flow +5 -5
- package/getRootVariablesForFragments.js.flow +1 -1
- package/hooks.d.ts +89 -0
- package/hooks.js +1 -1
- package/hooks.js.flow +23 -8
- package/index.d.ts +9 -0
- package/index.js +1 -1
- package/index.js.flow +40 -14
- package/isRelayEnvironment.js.flow +1 -1
- package/jest-react/internalAct.js.flow +1 -1
- package/legacy.d.ts +143 -0
- package/legacy.js +1 -1
- package/legacy.js.flow +32 -13
- package/lib/ReactRelayFragmentContainer.js +1 -1
- package/lib/ReactRelayPaginationContainer.js +8 -8
- package/lib/ReactRelayRefetchContainer.js +8 -8
- package/lib/ReactRelayTestMocker.js +5 -5
- package/lib/hooks.js +18 -8
- package/lib/index.js +30 -14
- package/lib/legacy.js +26 -13
- package/lib/relay-hooks/legacy/useBlockingPaginationFragment.js +5 -5
- package/lib/relay-hooks/legacy/useRefetchableFragmentNode.js +34 -34
- package/lib/relay-hooks/loadEntryPoint.js +2 -2
- package/lib/relay-hooks/loadQuery.js +14 -14
- package/lib/relay-hooks/preloadQuery_DEPRECATED.js +10 -10
- package/lib/relay-hooks/readFragmentInternal.js +6 -6
- package/lib/relay-hooks/rsc/serverFetchQuery.js +20 -0
- package/lib/relay-hooks/rsc/serverPreloadQuery.js +31 -0
- package/lib/relay-hooks/rsc/serverReadFragment.js +15 -0
- package/lib/relay-hooks/rsc/useQueryFromServer.js +62 -0
- package/lib/relay-hooks/useFragmentInternal_CURRENT.js +49 -25
- package/lib/relay-hooks/useFragmentInternal_EXPERIMENTAL.js +81 -44
- package/lib/relay-hooks/useLazyLoadQueryNode.js +32 -19
- package/lib/relay-hooks/useMutation.js +6 -14
- package/lib/relay-hooks/useMutationAction_EXPERIMENTAL.js +26 -0
- package/lib/relay-hooks/usePreloadedQuery.js +52 -47
- package/lib/relay-hooks/useQueryLoader.js +2 -2
- package/lib/relay-hooks/useQueryLoader_EXPERIMENTAL.js +2 -2
- package/lib/relay-hooks/useRefetchableFragmentInternal.js +31 -31
- package/lib/rsc-client_EXPERIMENTAL.js +7 -0
- package/lib/rsc_EXPERIMENTAL.js +43 -0
- package/multi-actor/ActorChange.js.flow +1 -1
- package/package.json +3 -2
- package/relay-hooks/EntryPointContainer.react.d.ts +22 -0
- package/relay-hooks/EntryPointContainer.react.js.flow +6 -6
- package/relay-hooks/EntryPointTypes.flow.js.flow +106 -108
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +23 -21
- package/relay-hooks/MatchContainer.d.ts +95 -0
- package/relay-hooks/MatchContainer.js.flow +17 -11
- package/relay-hooks/NestedRelayEntryPointBuilderUtils.js.flow +3 -9
- package/relay-hooks/ProfilerContext.d.ts +18 -0
- package/relay-hooks/QueryResource.js.flow +9 -9
- package/relay-hooks/RelayEnvironmentProvider.d.ts +16 -0
- package/relay-hooks/RelayEnvironmentProvider.js.flow +2 -2
- package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +6 -6
- package/relay-hooks/__flowtests__/EntryPointTypes/ExtractQueryTypes-flowtest.js.flow +50 -3
- package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +9 -9
- package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_user.graphql.js.flow +3 -4
- package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_users.graphql.js.flow +5 -6
- package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +27 -32
- package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +25 -25
- package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +26 -32
- package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +23 -30
- package/relay-hooks/__flowtests__/utils.js.flow +17 -17
- package/relay-hooks/getConnectionState.js.flow +2 -2
- package/relay-hooks/legacy/FragmentResource.js.flow +13 -13
- package/relay-hooks/legacy/useBlockingPaginationFragment.js.flow +28 -25
- package/relay-hooks/legacy/useFragmentNode.js.flow +4 -4
- package/relay-hooks/legacy/useRefetchableFragmentNode.js.flow +79 -81
- package/relay-hooks/loadEntryPoint.d.ts +14 -0
- package/relay-hooks/loadEntryPoint.js.flow +15 -13
- package/relay-hooks/loadQuery.d.ts +20 -0
- package/relay-hooks/loadQuery.js.flow +19 -19
- package/relay-hooks/preloadQuery_DEPRECATED.js.flow +16 -13
- package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +7 -7
- package/relay-hooks/readFragmentInternal.js.flow +11 -11
- package/relay-hooks/rsc/serverFetchQuery.js.flow +31 -0
- package/relay-hooks/rsc/serverPreloadQuery.js.flow +69 -0
- package/relay-hooks/rsc/serverReadFragment.js.flow +33 -0
- package/relay-hooks/rsc/useQueryFromServer.js.flow +135 -0
- package/relay-hooks/useClientQuery.d.ts +16 -0
- package/relay-hooks/useClientQuery.js.flow +2 -2
- package/relay-hooks/useEntryPointLoader.d.ts +21 -0
- package/relay-hooks/useEntryPointLoader.js.flow +11 -11
- package/relay-hooks/useFragment.d.ts +36 -0
- package/relay-hooks/useFragment.js.flow +8 -8
- package/relay-hooks/useFragmentInternal.js.flow +1 -1
- package/relay-hooks/useFragmentInternal_CURRENT.js.flow +54 -22
- package/relay-hooks/useFragmentInternal_EXPERIMENTAL.js.flow +95 -46
- package/relay-hooks/useIsOperationNodeActive.js.flow +1 -1
- package/relay-hooks/useIsParentQueryActive.js.flow +5 -1
- package/relay-hooks/useLazyLoadQuery.d.ts +19 -0
- package/relay-hooks/useLazyLoadQuery.js.flow +14 -7
- package/relay-hooks/useLazyLoadQueryNode.js.flow +67 -28
- package/relay-hooks/useLoadMoreFunction.d.ts +56 -0
- package/relay-hooks/useLoadMoreFunction.js.flow +7 -6
- package/relay-hooks/useLoadMoreFunction_EXPERIMENTAL.js.flow +5 -5
- package/relay-hooks/useMemoVariables.js.flow +1 -1
- package/relay-hooks/useMutation.d.ts +36 -0
- package/relay-hooks/useMutation.js.flow +9 -17
- package/relay-hooks/useMutationAction_EXPERIMENTAL.js.flow +68 -0
- package/relay-hooks/usePaginationFragment.d.ts +33 -0
- package/relay-hooks/usePaginationFragment.js.flow +19 -11
- package/relay-hooks/usePrefetchableForwardPaginationFragment.js.flow +23 -18
- package/relay-hooks/usePrefetchableForwardPaginationFragment_EXPERIMENTAL.js.flow +23 -18
- package/relay-hooks/usePreloadedQuery.d.ts +17 -0
- package/relay-hooks/usePreloadedQuery.js.flow +119 -85
- package/relay-hooks/useQueryLoader.d.ts +33 -0
- package/relay-hooks/useQueryLoader.js.flow +28 -24
- package/relay-hooks/useQueryLoader_EXPERIMENTAL.js.flow +10 -10
- package/relay-hooks/useRefetchableFragment.d.ts +23 -0
- package/relay-hooks/useRefetchableFragment.js.flow +20 -11
- package/relay-hooks/useRefetchableFragmentInternal.js.flow +77 -79
- package/relay-hooks/useRelayEnvironment.d.ts +10 -0
- package/relay-hooks/useRelayLoggingContext.js.flow +1 -1
- package/relay-hooks/useSubscribeToInvalidationState.d.ts +19 -0
- package/relay-hooks/useSubscribeToInvalidationState.js.flow +1 -1
- package/relay-hooks/useSubscription.d.ts +14 -0
- package/relay-hooks/useSubscription.js.flow +1 -1
- package/rsc-client_EXPERIMENTAL.d.ts +17 -0
- package/rsc-client_EXPERIMENTAL.js +10 -0
- package/rsc-client_EXPERIMENTAL.js.flow +23 -0
- package/rsc_EXPERIMENTAL.d.ts +48 -0
- package/rsc_EXPERIMENTAL.js +10 -0
- package/rsc_EXPERIMENTAL.js.flow +90 -0
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
import {
|
|
10
|
+
_FragmentRefs,
|
|
11
|
+
_RefType,
|
|
12
|
+
CacheConfig,
|
|
13
|
+
ConcreteRequest,
|
|
14
|
+
Disposable,
|
|
15
|
+
DisposeFn,
|
|
16
|
+
Environment,
|
|
17
|
+
FetchPolicy,
|
|
18
|
+
FragmentType,
|
|
19
|
+
GraphQLResponse,
|
|
20
|
+
IEnvironment,
|
|
21
|
+
Observable,
|
|
22
|
+
Observer,
|
|
23
|
+
OperationType,
|
|
24
|
+
PreloadableConcreteRequest,
|
|
25
|
+
RenderPolicy,
|
|
26
|
+
Variables,
|
|
27
|
+
VariablesOf,
|
|
28
|
+
} from 'relay-runtime';
|
|
29
|
+
|
|
30
|
+
export { FragmentRef } from 'relay-runtime';
|
|
31
|
+
export { VariablesOf } from 'relay-runtime';
|
|
32
|
+
|
|
33
|
+
// --- Legacy container types ---
|
|
34
|
+
|
|
35
|
+
export interface RelayProp {
|
|
36
|
+
environment: Environment;
|
|
37
|
+
refetch: undefined; // ensures no RelayRefetchProp is used with a fragment container
|
|
38
|
+
hasMore: undefined; // ensures no RelayPaginationProp is used with a fragment container
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface RelayRefetchProp {
|
|
42
|
+
environment: Environment;
|
|
43
|
+
refetch: (
|
|
44
|
+
refetchVariables: Variables | ((fragmentVariables: Variables) => Variables),
|
|
45
|
+
renderVariables?: Variables | null,
|
|
46
|
+
observerOrCallback?: ObserverOrCallback | null,
|
|
47
|
+
options?: RefetchOptions,
|
|
48
|
+
) => Disposable;
|
|
49
|
+
hasMore: undefined; // ensures no RelayPaginationProp is used with a refetch container
|
|
50
|
+
}
|
|
51
|
+
export interface RefetchOptions {
|
|
52
|
+
force?: boolean | undefined;
|
|
53
|
+
fetchPolicy?: 'store-or-network' | 'network-only' | undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
type ObserverOrCallback = Observer<void> | ((error: Error | null | undefined) => void);
|
|
57
|
+
|
|
58
|
+
export interface RelayPaginationProp {
|
|
59
|
+
readonly environment: Environment;
|
|
60
|
+
readonly hasMore: () => boolean;
|
|
61
|
+
readonly isLoading: () => boolean;
|
|
62
|
+
readonly loadMore: (
|
|
63
|
+
pageSize: number,
|
|
64
|
+
observerOrCallback?: ObserverOrCallback | null,
|
|
65
|
+
options?: RefetchOptions | null,
|
|
66
|
+
) => Disposable | null | undefined;
|
|
67
|
+
readonly refetchConnection: (
|
|
68
|
+
totalCount: number,
|
|
69
|
+
observerOrCallback?: ObserverOrCallback | null,
|
|
70
|
+
refetchVariables?: Variables | null,
|
|
71
|
+
) => Disposable | null | undefined;
|
|
72
|
+
refetch: undefined; // ensures no RelayRefetchProp is used with a pagination container
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type FragmentOrRegularProp<T> = T extends _RefType<infer U> ? _FragmentRefs<U>
|
|
76
|
+
: T extends ReadonlyArray<_RefType<infer U>> ? ReadonlyArray<_FragmentRefs<U>>
|
|
77
|
+
: T;
|
|
78
|
+
|
|
79
|
+
export type MappedFragmentProps<T> = {
|
|
80
|
+
[K in keyof T]: FragmentOrRegularProp<T[K]>;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// --- Fragment key types (from helpers) ---
|
|
84
|
+
|
|
85
|
+
export type KeyType<TData = unknown> = Readonly<{
|
|
86
|
+
' $data'?: TData | undefined;
|
|
87
|
+
' $fragmentSpreads': FragmentType;
|
|
88
|
+
}>;
|
|
89
|
+
|
|
90
|
+
export type KeyTypeData<TKey extends KeyType<TData>, TData = unknown> = Required<TKey>[' $data'];
|
|
91
|
+
|
|
92
|
+
export type ArrayKeyType<TData = unknown> = ReadonlyArray<KeyType<readonly TData[]> | null | undefined>;
|
|
93
|
+
export type ArrayKeyTypeData<TKey extends ArrayKeyType<TData>, TData = unknown> = KeyTypeData<
|
|
94
|
+
NonNullable<TKey[number]>
|
|
95
|
+
>;
|
|
96
|
+
|
|
97
|
+
export type GetEntryPointParamsFromEntryPoint<TEntryPoint> = TEntryPoint extends EntryPoint<
|
|
98
|
+
infer _TEntryPointComponent,
|
|
99
|
+
infer TEntryPointParams
|
|
100
|
+
> ? TEntryPointParams
|
|
101
|
+
: never;
|
|
102
|
+
|
|
103
|
+
export type GetEntryPointComponentFromEntryPoint<TEntryPoint> = TEntryPoint extends EntryPoint<
|
|
104
|
+
infer TEntryPointComponent,
|
|
105
|
+
infer _TEntryPointParams
|
|
106
|
+
> ? TEntryPointComponent
|
|
107
|
+
: never;
|
|
108
|
+
|
|
109
|
+
// --- EntryPoint types ---
|
|
110
|
+
|
|
111
|
+
export interface JSResourceReference<TModule> {
|
|
112
|
+
getModuleId(): string;
|
|
113
|
+
|
|
114
|
+
getModuleIfRequired(): TModule | null;
|
|
115
|
+
|
|
116
|
+
load(): Promise<TModule>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type PreloadFetchPolicy = 'store-or-network' | 'store-and-network' | 'network-only';
|
|
120
|
+
|
|
121
|
+
export type PreloadOptions = Readonly<{
|
|
122
|
+
fetchKey?: string | number | undefined;
|
|
123
|
+
fetchPolicy?: PreloadFetchPolicy | null | undefined;
|
|
124
|
+
networkCacheConfig?: CacheConfig | null | undefined;
|
|
125
|
+
}>;
|
|
126
|
+
|
|
127
|
+
export type LoadQueryOptions = Readonly<{
|
|
128
|
+
fetchPolicy?: FetchPolicy | null | undefined;
|
|
129
|
+
networkCacheConfig?: CacheConfig | null | undefined;
|
|
130
|
+
onQueryAstLoadTimeout?: (() => void) | null | undefined;
|
|
131
|
+
}>;
|
|
132
|
+
|
|
133
|
+
export type EnvironmentProviderOptions<T extends Record<string, unknown> = Record<string, unknown>> = T;
|
|
134
|
+
|
|
135
|
+
export type PreloadedQuery<
|
|
136
|
+
TQuery extends OperationType,
|
|
137
|
+
TEnvironmentProviderOptions = EnvironmentProviderOptions,
|
|
138
|
+
> = Readonly<{
|
|
139
|
+
kind: 'PreloadedQuery';
|
|
140
|
+
environment: IEnvironment;
|
|
141
|
+
environmentProviderOptions?: TEnvironmentProviderOptions | null | undefined;
|
|
142
|
+
fetchKey: string | number;
|
|
143
|
+
fetchPolicy: PreloadFetchPolicy;
|
|
144
|
+
networkCacheConfig?: CacheConfig | null | undefined;
|
|
145
|
+
id?: string | null | undefined;
|
|
146
|
+
name: string;
|
|
147
|
+
source?: Observable<GraphQLResponse> | null | undefined;
|
|
148
|
+
variables: VariablesOf<TQuery>;
|
|
149
|
+
dispose: DisposeFn;
|
|
150
|
+
isDisposed: boolean;
|
|
151
|
+
}>;
|
|
152
|
+
|
|
153
|
+
export type PreloadQueryStatus = Readonly<{
|
|
154
|
+
cacheConfig?: CacheConfig | null | undefined;
|
|
155
|
+
source: 'cache' | 'network';
|
|
156
|
+
fetchTime?: number | null | undefined;
|
|
157
|
+
}>;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The Interface of the EntryPoints .entrypoint files
|
|
161
|
+
*
|
|
162
|
+
* Every .entrypoint file it's an object that must have two required fields:
|
|
163
|
+
* - getPreloadProps(...) function that will return the description of preloaded
|
|
164
|
+
* queries and preloaded (nested) entry points for the current entry point
|
|
165
|
+
* - root - JSResource of the module that will render those preloaded queries
|
|
166
|
+
*
|
|
167
|
+
* TEntryPointParams - object that contains all necessary information to execute
|
|
168
|
+
* the preloaders (routeParams, query variables)
|
|
169
|
+
*
|
|
170
|
+
* TPreloadedQueries - queries, defined in the root components
|
|
171
|
+
*
|
|
172
|
+
* TNestedEntryPoints - nested entry points, defined in the root components
|
|
173
|
+
*
|
|
174
|
+
* TRuntimeProps - the type of additional props that you may pass to the
|
|
175
|
+
* component (like `onClick` handler, etc) during runtime. Values for them
|
|
176
|
+
* defined during component runtime
|
|
177
|
+
*
|
|
178
|
+
* TExtraProps - a bag of extra props that you may define in `entrypoint` file
|
|
179
|
+
* and they will be passed to the EntryPointComponent as `extraProps`
|
|
180
|
+
*/
|
|
181
|
+
type InternalEntryPointRepresentation<
|
|
182
|
+
TEntryPointParams extends Record<string, unknown>,
|
|
183
|
+
TPreloadedQueries extends Record<string, OperationType>,
|
|
184
|
+
TNestedEntryPoints extends Record<string, unknown>,
|
|
185
|
+
TRuntimeProps extends Record<string, unknown>,
|
|
186
|
+
TExtraProps extends Record<string, unknown> | null,
|
|
187
|
+
> = Readonly<{
|
|
188
|
+
root: JSResourceReference<
|
|
189
|
+
EntryPointComponent<TPreloadedQueries, TNestedEntryPoints, TRuntimeProps, TExtraProps>
|
|
190
|
+
>;
|
|
191
|
+
getPreloadProps: (
|
|
192
|
+
entryPointParams: TEntryPointParams,
|
|
193
|
+
) => PreloadProps<TEntryPointParams, TPreloadedQueries, TNestedEntryPoints, TExtraProps>;
|
|
194
|
+
}>;
|
|
195
|
+
|
|
196
|
+
type ThinQueryParamsObject<TPreloadedQueries extends Record<string, OperationType> = Record<string, never>> = {
|
|
197
|
+
[K in keyof TPreloadedQueries]: ThinQueryParams<TPreloadedQueries[K]>;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
type ThinNestedEntryPointParamsObject<
|
|
201
|
+
TEntryPoints extends Record<string, EntryPoint<any, any> | undefined> = Record<string, never>,
|
|
202
|
+
> = {
|
|
203
|
+
[K in keyof TEntryPoints]: ThinNestedEntryPointParams<TEntryPoints[K]>;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
type PreloadedQueries<TPreloadedQueries> = TPreloadedQueries extends Record<string, OperationType> ? {
|
|
207
|
+
[T in keyof TPreloadedQueries]: PreloadedQuery<TPreloadedQueries[T]>;
|
|
208
|
+
}
|
|
209
|
+
: never;
|
|
210
|
+
|
|
211
|
+
type PreloadedEntryPoints<TEntryPoints> = TEntryPoints extends Record<
|
|
212
|
+
string,
|
|
213
|
+
InternalEntryPointRepresentation<any, any, any, any, any> | undefined
|
|
214
|
+
> ? {
|
|
215
|
+
[T in keyof TEntryPoints]: PreloadedEntryPoint<
|
|
216
|
+
GetEntryPointComponentFromEntryPoint<TEntryPoints[T]>
|
|
217
|
+
>;
|
|
218
|
+
}
|
|
219
|
+
: never;
|
|
220
|
+
|
|
221
|
+
export type PreloadProps<
|
|
222
|
+
_TPreloadParams extends Record<string, unknown>,
|
|
223
|
+
TPreloadedQueries extends Record<string, OperationType>,
|
|
224
|
+
TNestedEntryPoints extends Record<string, EntryPoint<any, any> | undefined>,
|
|
225
|
+
TExtraProps extends Record<string, unknown> | null,
|
|
226
|
+
> = Readonly<{
|
|
227
|
+
entryPoints?: ThinNestedEntryPointParamsObject<TNestedEntryPoints> | undefined;
|
|
228
|
+
extraProps?: TExtraProps | undefined;
|
|
229
|
+
queries?: ThinQueryParamsObject<TPreloadedQueries> | undefined;
|
|
230
|
+
}>;
|
|
231
|
+
|
|
232
|
+
export type EntryPointProps<TPreloadedQueries, TNestedEntryPoints, TRuntimeProps, TExtraProps> = Readonly<{
|
|
233
|
+
entryPoints: PreloadedEntryPoints<TNestedEntryPoints>;
|
|
234
|
+
extraProps: TExtraProps;
|
|
235
|
+
props: TRuntimeProps;
|
|
236
|
+
queries: PreloadedQueries<TPreloadedQueries>;
|
|
237
|
+
}>;
|
|
238
|
+
|
|
239
|
+
export type EntryPointComponent<
|
|
240
|
+
TPreloadedQueries extends Record<string, OperationType>,
|
|
241
|
+
TNestedEntryPoints extends Record<string, EntryPoint<any, any> | undefined>,
|
|
242
|
+
TRuntimeProps extends Record<string, unknown> = Record<string, unknown>,
|
|
243
|
+
TExtraProps extends Record<string, unknown> | null = Record<string, unknown>,
|
|
244
|
+
> = React.ComponentType<EntryPointProps<TPreloadedQueries, TNestedEntryPoints, TRuntimeProps, TExtraProps>>;
|
|
245
|
+
|
|
246
|
+
export type PreloadedEntryPoint<TEntryPointComponent> = TEntryPointComponent extends EntryPointComponent<
|
|
247
|
+
infer TPreloadedQueries,
|
|
248
|
+
infer TNestedEntryPoints,
|
|
249
|
+
infer _TRuntimeProps,
|
|
250
|
+
infer TExtraProps
|
|
251
|
+
> ? Readonly<{
|
|
252
|
+
dispose: DisposeFn;
|
|
253
|
+
entryPoints: PreloadedEntryPoints<TNestedEntryPoints>;
|
|
254
|
+
extraProps: TExtraProps;
|
|
255
|
+
getComponent: () => TEntryPointComponent;
|
|
256
|
+
isDisposed: boolean;
|
|
257
|
+
queries: PreloadedQueries<TPreloadedQueries>;
|
|
258
|
+
rootModuleID: string;
|
|
259
|
+
}>
|
|
260
|
+
: never;
|
|
261
|
+
|
|
262
|
+
export type ThinQueryParams<
|
|
263
|
+
TQuery extends OperationType,
|
|
264
|
+
TEnvironmentProviderOptions extends EnvironmentProviderOptions = EnvironmentProviderOptions,
|
|
265
|
+
> = Readonly<{
|
|
266
|
+
parameters: ConcreteRequest | PreloadableConcreteRequest<TQuery>;
|
|
267
|
+
variables: VariablesOf<TQuery>;
|
|
268
|
+
options?: PreloadOptions | null | undefined;
|
|
269
|
+
environmentProviderOptions?: TEnvironmentProviderOptions | null | undefined;
|
|
270
|
+
}>;
|
|
271
|
+
|
|
272
|
+
export type ThinNestedEntryPointParams<TEntryPoint> = Readonly<{
|
|
273
|
+
entryPoint: TEntryPoint;
|
|
274
|
+
entryPointParams: GetEntryPointParamsFromEntryPoint<TEntryPoint>;
|
|
275
|
+
}>;
|
|
276
|
+
|
|
277
|
+
export type EntryPoint<TEntryPointComponent, TEntryPointParams extends Record<string, unknown> = Record<string, unknown>> = InternalEntryPointRepresentation<
|
|
278
|
+
TEntryPointParams,
|
|
279
|
+
TEntryPointComponent extends EntryPointComponent<infer TPreloadedQueries, any, any, any> ? TPreloadedQueries
|
|
280
|
+
: never,
|
|
281
|
+
TEntryPointComponent extends EntryPointComponent<any, infer TNestedEntryPoints, any, any> ? TNestedEntryPoints
|
|
282
|
+
: never,
|
|
283
|
+
TEntryPointComponent extends EntryPointComponent<any, any, infer TRuntimeProps, any> ? TRuntimeProps : never,
|
|
284
|
+
TEntryPointComponent extends EntryPointComponent<any, any, any, infer TExtraProps> ? TExtraProps : never
|
|
285
|
+
>;
|
|
286
|
+
|
|
287
|
+
export interface IEnvironmentProvider<TOptions> {
|
|
288
|
+
getEnvironment(options: TOptions | null): IEnvironment;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// --- Refetchable fragment types (from useRefetchableFragmentNode) ---
|
|
292
|
+
|
|
293
|
+
export type RefetchFn<TQuery extends OperationType, TOptions = RefetchableOptions> = RefetchFnExact<TQuery, TOptions>;
|
|
294
|
+
|
|
295
|
+
export type RefetchFnDynamic<
|
|
296
|
+
TQuery extends OperationType,
|
|
297
|
+
_TKey extends KeyType | null | undefined,
|
|
298
|
+
TOptions = RefetchableOptions,
|
|
299
|
+
> = RefetchInexactDynamicResponse<TQuery, TOptions> & RefetchExactDynamicResponse<TQuery, TOptions>;
|
|
300
|
+
|
|
301
|
+
export type RefetchInexact<TQuery extends OperationType, TOptions> = (
|
|
302
|
+
data?: unknown,
|
|
303
|
+
) => RefetchFnInexact<TQuery, TOptions>;
|
|
304
|
+
export type RefetchInexactDynamicResponse<TQuery extends OperationType, TOptions> = ReturnType<
|
|
305
|
+
RefetchInexact<TQuery, TOptions>
|
|
306
|
+
>;
|
|
307
|
+
|
|
308
|
+
export type RefetchExact<TQuery extends OperationType, TOptions> = (
|
|
309
|
+
data?: unknown | null,
|
|
310
|
+
) => RefetchFnExact<TQuery, TOptions>;
|
|
311
|
+
export type RefetchExactDynamicResponse<TQuery extends OperationType, TOptions> = ReturnType<
|
|
312
|
+
RefetchExact<TQuery, TOptions>
|
|
313
|
+
>;
|
|
314
|
+
|
|
315
|
+
export type RefetchFnBase<TVars, TOptions> = (vars: TVars, options?: TOptions) => Disposable;
|
|
316
|
+
|
|
317
|
+
export type RefetchFnExact<TQuery extends OperationType, TOptions = RefetchableOptions> = RefetchFnBase<
|
|
318
|
+
VariablesOf<TQuery>,
|
|
319
|
+
TOptions
|
|
320
|
+
>;
|
|
321
|
+
export type RefetchFnInexact<TQuery extends OperationType, TOptions = RefetchableOptions> = RefetchFnBase<
|
|
322
|
+
Partial<VariablesOf<TQuery>>,
|
|
323
|
+
TOptions
|
|
324
|
+
>;
|
|
325
|
+
|
|
326
|
+
export interface ReturnTypeNode<
|
|
327
|
+
TQuery extends OperationType,
|
|
328
|
+
TKey extends KeyType | null | undefined,
|
|
329
|
+
TOptions = RefetchableOptions,
|
|
330
|
+
> {
|
|
331
|
+
fragmentData: unknown;
|
|
332
|
+
fragmentRef: unknown;
|
|
333
|
+
refetch: RefetchFnDynamic<TQuery, TKey, TOptions>;
|
|
334
|
+
disableStoreUpdates: () => void;
|
|
335
|
+
enableStoreUpdates: () => void;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export interface RefetchableOptions {
|
|
339
|
+
fetchPolicy?: FetchPolicy | undefined;
|
|
340
|
+
onComplete?: ((arg: Error | null) => void) | undefined;
|
|
341
|
+
UNSTABLE_renderPolicy?: RenderPolicy | undefined;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export interface InternalRefetchableOptions extends RefetchableOptions {
|
|
345
|
+
__environment?: IEnvironment | undefined;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export type RefetchableAction =
|
|
349
|
+
| {
|
|
350
|
+
type: 'reset';
|
|
351
|
+
environment: IEnvironment;
|
|
352
|
+
fragmentIdentifier: string;
|
|
353
|
+
}
|
|
354
|
+
| {
|
|
355
|
+
type: 'refetch';
|
|
356
|
+
refetchVariables: Variables;
|
|
357
|
+
fetchPolicy?: FetchPolicy | undefined;
|
|
358
|
+
renderPolicy?: RenderPolicy | undefined;
|
|
359
|
+
onComplete?: ((args: Error | null) => void) | undefined;
|
|
360
|
+
environment?: IEnvironment | null | undefined;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
export interface RefetchState {
|
|
364
|
+
fetchPolicy?: FetchPolicy | undefined;
|
|
365
|
+
renderPolicy?: RenderPolicy | undefined;
|
|
366
|
+
mirroredEnvironment: IEnvironment;
|
|
367
|
+
mirroredFragmentIdentifier: string;
|
|
368
|
+
onComplete?: ((arg: Error | null) => void) | undefined;
|
|
369
|
+
refetchEnvironment?: IEnvironment | null | undefined;
|
|
370
|
+
refetchVariables?: Variables | null | undefined;
|
|
371
|
+
refetchGeneration: number;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export interface DebugIDandTypename {
|
|
375
|
+
id: string;
|
|
376
|
+
typename: string;
|
|
377
|
+
}
|
package/ReactRelayTypes.js.flow
CHANGED
|
@@ -22,22 +22,22 @@ import type {
|
|
|
22
22
|
|
|
23
23
|
export type GeneratedNodeMap = {[key: string]: GraphQLTaggedNode, ...};
|
|
24
24
|
|
|
25
|
-
export type ObserverOrCallback = Observer<void> | ((error: ?Error) =>
|
|
25
|
+
export type ObserverOrCallback = Observer<void> | ((error: ?Error) => unknown);
|
|
26
26
|
|
|
27
27
|
// NOTE: This is an inexact type in order to allow a RelayPaginationProp or
|
|
28
28
|
// RelayRefetchProp to flow into a RelayProp.
|
|
29
|
-
export type RelayProp = {
|
|
29
|
+
export type RelayProp = {readonly environment: IEnvironment, ...};
|
|
30
30
|
|
|
31
31
|
export type RelayPaginationProp = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
readonly environment: IEnvironment,
|
|
33
|
+
readonly hasMore: () => boolean,
|
|
34
|
+
readonly isLoading: () => boolean,
|
|
35
|
+
readonly loadMore: (
|
|
36
36
|
pageSize: number,
|
|
37
37
|
observerOrCallback: ?ObserverOrCallback,
|
|
38
38
|
options?: RefetchOptions,
|
|
39
39
|
) => ?Disposable,
|
|
40
|
-
|
|
40
|
+
readonly refetchConnection: (
|
|
41
41
|
totalCount: number,
|
|
42
42
|
observerOrCallback: ?ObserverOrCallback,
|
|
43
43
|
refetchVariables: ?Variables,
|
|
@@ -45,8 +45,8 @@ export type RelayPaginationProp = {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
export type RelayRefetchProp = {
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
readonly environment: IEnvironment,
|
|
49
|
+
readonly refetch: (
|
|
50
50
|
refetchVariables: Variables | ((fragmentVariables: Variables) => Variables),
|
|
51
51
|
renderVariables: ?Variables,
|
|
52
52
|
observerOrCallback: ?ObserverOrCallback,
|
|
@@ -55,9 +55,9 @@ export type RelayRefetchProp = {
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
export type RefetchOptions = {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
readonly force?: boolean,
|
|
59
|
+
readonly fetchPolicy?: 'store-or-network' | 'network-only',
|
|
60
|
+
readonly metadata?: {[key: string]: unknown, ...},
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
/**
|
|
@@ -93,15 +93,15 @@ export type RefetchOptions = {
|
|
|
93
93
|
*
|
|
94
94
|
*/
|
|
95
95
|
export type $FragmentRef<T> = {
|
|
96
|
-
|
|
96
|
+
readonly $fragmentSpreads: T['$fragmentType'],
|
|
97
97
|
...
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
/* $FlowExpectedError[unclear-type]: Intentional so that it won't fail,
|
|
101
101
|
* even if the type we want to exclude doesn't exist in Props */
|
|
102
|
-
type LooseOmitRelayProps<Props, K
|
|
102
|
+
type LooseOmitRelayProps<Props, K extends keyof any> = Pick<
|
|
103
103
|
Props,
|
|
104
|
-
Exclude
|
|
104
|
+
Exclude<keyof Props, K>,
|
|
105
105
|
>;
|
|
106
106
|
/**
|
|
107
107
|
* A utility type that takes the Props of a component and the type of
|
|
@@ -114,51 +114,55 @@ export type $RelayProps<Props, _RelayPropT = RelayProp> = MapRelayProps<
|
|
|
114
114
|
>;
|
|
115
115
|
|
|
116
116
|
type MapRelayProps<Props> = {[K in keyof Props]: MapRelayProp<Props[K]>};
|
|
117
|
-
type MapRelayProp<T> = [
|
|
117
|
+
type MapRelayProp<T> = [readonly t: T] extends [
|
|
118
|
+
readonly t: {readonly $fragmentType: empty, ...},
|
|
119
|
+
]
|
|
118
120
|
? T
|
|
119
|
-
: [
|
|
121
|
+
: [readonly t: T] extends [readonly t: ?{readonly $fragmentType: empty, ...}]
|
|
120
122
|
? ?T
|
|
121
|
-
: [
|
|
123
|
+
: [readonly t: T] extends [
|
|
124
|
+
readonly t: {readonly $fragmentType: FragmentType, ...},
|
|
125
|
+
]
|
|
122
126
|
? $FragmentRef<T>
|
|
123
|
-
: [
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
: [readonly t: T] extends [
|
|
128
|
+
readonly t: ?{readonly $fragmentType: FragmentType, ...},
|
|
129
|
+
]
|
|
130
|
+
? ?$FragmentRef<NonNullable<T>>
|
|
131
|
+
: [readonly t: T] extends [
|
|
132
|
+
readonly t: ReadonlyArray<
|
|
133
|
+
infer V extends {readonly $fragmentType: FragmentType, ...},
|
|
128
134
|
>,
|
|
129
135
|
]
|
|
130
|
-
?
|
|
131
|
-
: [
|
|
132
|
-
|
|
133
|
-
infer V extends {
|
|
136
|
+
? ReadonlyArray<$FragmentRef<V>>
|
|
137
|
+
: [readonly t: T] extends [
|
|
138
|
+
readonly t: ?ReadonlyArray<
|
|
139
|
+
infer V extends {readonly $fragmentType: FragmentType, ...},
|
|
134
140
|
>,
|
|
135
141
|
]
|
|
136
|
-
?
|
|
137
|
-
: [
|
|
138
|
-
|
|
139
|
-
|
|
142
|
+
? ?ReadonlyArray<$FragmentRef<V>>
|
|
143
|
+
: [readonly t: T] extends [
|
|
144
|
+
readonly t: ReadonlyArray<?infer V extends {
|
|
145
|
+
readonly $fragmentType: FragmentType,
|
|
140
146
|
...
|
|
141
147
|
}>,
|
|
142
148
|
]
|
|
143
|
-
?
|
|
144
|
-
: [
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
? ReadonlyArray<?$FragmentRef<NonNullable<V>>>
|
|
150
|
+
: [readonly t: T] extends [
|
|
151
|
+
readonly t: ?ReadonlyArray<?infer V extends {
|
|
152
|
+
readonly $fragmentType: FragmentType,
|
|
147
153
|
...
|
|
148
154
|
}>,
|
|
149
155
|
]
|
|
150
|
-
?
|
|
156
|
+
? ?ReadonlyArray<?$FragmentRef<NonNullable<V>>>
|
|
151
157
|
: T;
|
|
152
158
|
|
|
153
|
-
export type RelayFragmentContainer<TComponent
|
|
154
|
-
...$RelayProps<React.ElementConfig<TComponent>, RelayProp>
|
|
155
|
-
);
|
|
159
|
+
export type RelayFragmentContainer<TComponent extends component(...empty)> =
|
|
160
|
+
component(...$RelayProps<React.ElementConfig<TComponent>, RelayProp>);
|
|
156
161
|
|
|
157
|
-
export type RelayPaginationContainer<TComponent
|
|
162
|
+
export type RelayPaginationContainer<TComponent extends component(...empty)> =
|
|
158
163
|
component(
|
|
159
164
|
...$RelayProps<React.ElementConfig<TComponent>, RelayPaginationProp>
|
|
160
165
|
);
|
|
161
166
|
|
|
162
|
-
export type RelayRefetchContainer<TComponent
|
|
163
|
-
...$RelayProps<React.ElementConfig<TComponent>, RelayRefetchProp>
|
|
164
|
-
);
|
|
167
|
+
export type RelayRefetchContainer<TComponent extends component(...empty)> =
|
|
168
|
+
component(...$RelayProps<React.ElementConfig<TComponent>, RelayRefetchProp>);
|
package/RelayContext.js.flow
CHANGED
|
@@ -20,21 +20,21 @@ const invariant = require('invariant');
|
|
|
20
20
|
* Asserts that the input is a matches the `RelayContext` type defined in
|
|
21
21
|
* `RelayEnvironmentTypes` and returns it as that type.
|
|
22
22
|
*/
|
|
23
|
-
function assertRelayContext(relay:
|
|
23
|
+
function assertRelayContext(relay: unknown): RelayContext {
|
|
24
24
|
invariant(
|
|
25
25
|
isRelayContext(relay),
|
|
26
26
|
'RelayContext: Expected `context.relay` to be an object conforming to ' +
|
|
27
27
|
'the `RelayContext` interface, got `%s`.',
|
|
28
28
|
relay,
|
|
29
29
|
);
|
|
30
|
-
return
|
|
30
|
+
return relay as any;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Determine if the input is a plain object that matches the `RelayContext`
|
|
35
35
|
* type defined in `RelayEnvironmentTypes`.
|
|
36
36
|
*/
|
|
37
|
-
function isRelayContext(context:
|
|
37
|
+
function isRelayContext(context: unknown): boolean {
|
|
38
38
|
return (
|
|
39
39
|
typeof context === 'object' &&
|
|
40
40
|
context !== null &&
|
|
@@ -54,10 +54,10 @@ class BarComponent extends React.Component<{
|
|
|
54
54
|
const reqLen = this.props.requiredProp.length;
|
|
55
55
|
const optionalProp = this.props.optionalProp;
|
|
56
56
|
|
|
57
|
-
/** $FlowExpectedError: `optionalProp` might be null **/
|
|
57
|
+
/** $FlowExpectedError[incompatible-use] : `optionalProp` might be null **/
|
|
58
58
|
const optionalFoo = this.props.optionalProp.foo;
|
|
59
59
|
|
|
60
|
-
/** $FlowExpectedError: there is no prop `missingProp` **/
|
|
60
|
+
/** $FlowExpectedError[prop-missing] : there is no prop `missingProp` **/
|
|
61
61
|
const missing = this.props.missingProp;
|
|
62
62
|
|
|
63
63
|
const defLen = this.props.defaultProp.length; // always a valid string, so no error
|
|
@@ -78,7 +78,7 @@ const Bar = createFragmentContainer(BarComponent, {
|
|
|
78
78
|
|
|
79
79
|
module.exports = {
|
|
80
80
|
checkMissingPropOnFunctionalComponent(): React.Node {
|
|
81
|
-
/** $FlowExpectedError: Foo missing `requiredProp` **/
|
|
81
|
+
/** $FlowExpectedError[incompatible-type] : Foo missing `requiredProp` **/
|
|
82
82
|
return <Foo />;
|
|
83
83
|
},
|
|
84
84
|
checkMinimalPropsOnFunctionalComponent(): React.Node {
|
|
@@ -86,7 +86,7 @@ module.exports = {
|
|
|
86
86
|
return <Foo requiredProp="foo" />;
|
|
87
87
|
},
|
|
88
88
|
checkMissingPropOnClassComponent(): React.Node {
|
|
89
|
-
/** $FlowExpectedError: Bar missing `requiredProp` **/
|
|
89
|
+
/** $FlowExpectedError[incompatible-type] : Bar missing `requiredProp` **/
|
|
90
90
|
return <Bar />;
|
|
91
91
|
},
|
|
92
92
|
checkMinimalPropsOnClassComponent(): React.Node {
|
|
@@ -94,19 +94,19 @@ module.exports = {
|
|
|
94
94
|
return <Bar requiredProp="foo" />;
|
|
95
95
|
},
|
|
96
96
|
checkWrongPropType(): React.Node {
|
|
97
|
-
/** $FlowExpectedError: Bar wrong `requiredProp` type, should be string **/
|
|
97
|
+
/** $FlowExpectedError[incompatible-type] : Bar wrong `requiredProp` type, should be string **/
|
|
98
98
|
return <Bar requiredProp={17} />;
|
|
99
99
|
},
|
|
100
100
|
checkWrongOptionalType(): React.Node {
|
|
101
|
-
/** $FlowExpectedError: Bar wrong `optionalProp` type, should be `{foo: string}` **/
|
|
101
|
+
/** $FlowExpectedError[incompatible-type] : Bar wrong `optionalProp` type, should be `{foo: string}` **/
|
|
102
102
|
return <Bar optionalProp="wrongType" requiredProp="foo" />;
|
|
103
103
|
},
|
|
104
104
|
checkNullOptionalType(): React.Node {
|
|
105
|
-
/** $FlowExpectedError: Bar `optionalProp` must be omitted or truthy, not null **/
|
|
105
|
+
/** $FlowExpectedError[incompatible-type] : Bar `optionalProp` must be omitted or truthy, not null **/
|
|
106
106
|
return <Bar optionalProp={null} requiredProp="foo" />;
|
|
107
107
|
},
|
|
108
108
|
checkWrongDefaultPropType(): React.Node {
|
|
109
|
-
/** $FlowExpectedError: Bar wrong `defaultProp` type, should be string **/
|
|
109
|
+
/** $FlowExpectedError[incompatible-type] : Bar wrong `defaultProp` type, should be string **/
|
|
110
110
|
return <Bar defaultProp={false} requiredProp="foo" />;
|
|
111
111
|
},
|
|
112
112
|
checkAllPossibleProps(): React.Node {
|
|
@@ -122,7 +122,7 @@ module.exports = {
|
|
|
122
122
|
},
|
|
123
123
|
checkMissingPropSpread(): React.Node {
|
|
124
124
|
const props = {defaultProp: 'foo'};
|
|
125
|
-
/** $FlowExpectedError: Bar missing `requiredProp` with spread **/
|
|
125
|
+
/** $FlowExpectedError[incompatible-type] : Bar missing `requiredProp` with spread **/
|
|
126
126
|
return <Bar {...props} />;
|
|
127
127
|
},
|
|
128
128
|
checkStaticsAndMethodsProxying(): React.Node {
|
|
@@ -131,10 +131,10 @@ module.exports = {
|
|
|
131
131
|
getString(): string {
|
|
132
132
|
const ok = this._barRef ? this._barRef.getNum() : 'default'; // legit
|
|
133
133
|
|
|
134
|
-
/** $FlowExpectedError: Bar does not have `missingMethod` **/
|
|
134
|
+
/** $FlowExpectedError[prop-missing] : Bar does not have `missingMethod` **/
|
|
135
135
|
const bad = this._barRef ? this._barRef.missingMethod() : 'default';
|
|
136
136
|
|
|
137
|
-
/** $FlowExpectedError: Bar `getNum` gives number, but `getString` assumes string **/
|
|
137
|
+
/** $FlowExpectedError[incompatible-type] : Bar `getNum` gives number, but `getString` assumes string **/
|
|
138
138
|
return bad ? 'not good' : ok;
|
|
139
139
|
}
|
|
140
140
|
render(): React.MixedElement {
|
|
@@ -39,10 +39,10 @@ class FooComponent extends React.Component<$FlowFixMe> {
|
|
|
39
39
|
const reqLen = this.props.requiredProp.length;
|
|
40
40
|
const optionalProp = this.props.optionalProp;
|
|
41
41
|
|
|
42
|
-
/** $FlowExpectedError: `optionalProp` might be null **/
|
|
42
|
+
/** $FlowExpectedError[incompatible-use] : `optionalProp` might be null **/
|
|
43
43
|
const optionalFoo = this.props.optionalProp.foo;
|
|
44
44
|
|
|
45
|
-
/** $FlowExpectedError: there is no prop `missingProp` **/
|
|
45
|
+
/** $FlowExpectedError[prop-missing] : there is no prop `missingProp` **/
|
|
46
46
|
const missing = this.props.missingProp;
|
|
47
47
|
|
|
48
48
|
const defLen = this.props.defaultProp.length; // always a valid string, so no error
|
|
@@ -140,7 +140,7 @@ module.exports = {
|
|
|
140
140
|
return <Foo {...props} />;
|
|
141
141
|
},
|
|
142
142
|
checkStaticsAndMethodsProxying(): React.Node {
|
|
143
|
-
/* $FlowFixMe(>=0.53.0) This comment suppresses an
|
|
143
|
+
/* $FlowFixMe[missing-type-arg](>=0.53.0) This comment suppresses an
|
|
144
144
|
* error when upgrading Flow's support for React. Common errors found when
|
|
145
145
|
* upgrading Flow's React support are documented at
|
|
146
146
|
* https://fburl.com/eq7bs81w */
|
|
@@ -149,10 +149,10 @@ module.exports = {
|
|
|
149
149
|
getString(): string {
|
|
150
150
|
const ok = this._fooRef ? this._fooRef.getNum() : 'default'; // legit
|
|
151
151
|
|
|
152
|
-
/** $FlowExpectedError: Foo does not have `missingMethod` **/
|
|
152
|
+
/** $FlowExpectedError[prop-missing] : Foo does not have `missingMethod` **/
|
|
153
153
|
const bad = this._fooRef ? this._fooRef.missingMethod() : 'default';
|
|
154
154
|
|
|
155
|
-
/** $FlowExpectedError: Foo `getNum` gives number, but `getString` assumes string **/
|
|
155
|
+
/** $FlowExpectedError[incompatible-type] : Foo `getNum` gives number, but `getString` assumes string **/
|
|
156
156
|
return bad ? 'not good' : ok;
|
|
157
157
|
}
|
|
158
158
|
render(): React.Node {
|