Skip to content

Commit e0120ee

Browse files
rubennortemeta-codesync[bot]
authored andcommitted
Revert variance annotation codemod in react-native-github (#56998)
Summary: Pull Request resolved: #56998 Reverts the codemod that replaced `+T` Flow variance annotations with the newer `out T` syntax across files in `packages/react-native` and `packages/react-native-codegen`. No runtime behavior changes; this is purely a Flow type-annotation revert. Changelog: [Internal] Differential Revision: D106813102
1 parent 622941d commit e0120ee

17 files changed

Lines changed: 32 additions & 34 deletions

File tree

packages/react-native-codegen/src/CodegenSchema.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ export type ArrayBufferTypeAnnotation = Readonly<{
7272
type: 'ArrayBufferTypeAnnotation',
7373
}>;
7474

75-
export type ObjectTypeAnnotation<out T> = Readonly<{
75+
export type ObjectTypeAnnotation<+T> = Readonly<{
7676
type: 'ObjectTypeAnnotation',
7777
properties: ReadonlyArray<NamedShape<T>>,
7878
// metadata for objects that generated from interfaces
7979
baseTypes?: ReadonlyArray<string>,
8080
}>;
8181

82-
export type UnionTypeAnnotation<out T> = Readonly<{
82+
export type UnionTypeAnnotation<+T> = Readonly<{
8383
type: 'UnionTypeAnnotation',
8484
types: ReadonlyArray<T>,
8585
}>;
@@ -93,13 +93,13 @@ export type EventEmitterTypeAnnotation = Readonly<{
9393
typeAnnotation: NativeModuleEventEmitterTypeAnnotation | $FlowFixMe,
9494
}>;
9595

96-
type FunctionTypeAnnotation<out P, out R> = Readonly<{
96+
type FunctionTypeAnnotation<+P, +R> = Readonly<{
9797
type: 'FunctionTypeAnnotation',
9898
params: ReadonlyArray<NamedShape<P>>,
9999
returnTypeAnnotation: R,
100100
}>;
101101

102-
export type NamedShape<out T> = Readonly<{
102+
export type NamedShape<+T> = Readonly<{
103103
name: string,
104104
optional: boolean,
105105
typeAnnotation: T,
@@ -195,7 +195,7 @@ export type ComponentCommandArrayTypeAnnotation = ArrayTypeAnnotation<
195195
| MixedTypeAnnotation,
196196
>;
197197

198-
export type ArrayTypeAnnotation<out T> = Readonly<{
198+
export type ArrayTypeAnnotation<+T> = Readonly<{
199199
type: 'ArrayTypeAnnotation',
200200
elementType: T,
201201
}>;
@@ -269,11 +269,11 @@ export type ReservedTypeAnnotation = Readonly<{
269269
/**
270270
* NativeModule Types
271271
*/
272-
export type Nullable<out T extends NativeModuleTypeAnnotation> =
272+
export type Nullable<+T extends NativeModuleTypeAnnotation> =
273273
| NullableTypeAnnotation<T>
274274
| T;
275275

276-
export type NullableTypeAnnotation<out T extends NativeModuleTypeAnnotation> =
276+
export type NullableTypeAnnotation<+T extends NativeModuleTypeAnnotation> =
277277
Readonly<{
278278
type: 'NullableTypeAnnotation',
279279
typeAnnotation: T,
@@ -321,7 +321,7 @@ export type NativeModuleObjectTypeAnnotation = ObjectTypeAnnotation<
321321
>;
322322

323323
export type NativeModuleArrayTypeAnnotation<
324-
out T extends Nullable<NativeModuleBaseTypeAnnotation>,
324+
+T extends Nullable<NativeModuleBaseTypeAnnotation>,
325325
> = ArrayTypeAnnotation<
326326
| T
327327
/**

packages/react-native-codegen/src/parsers/flow/components/componentsUtils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const {verifyPropNotAlreadyDefined} = require('../../parsers-commons');
1717
const {getValueFromTypes} = require('../utils.js');
1818

1919
// $FlowFixMe[unsupported-variance-annotation]
20-
function getTypeAnnotationForArray<out T>(
20+
function getTypeAnnotationForArray<+T>(
2121
name: string,
2222
typeAnnotation: $FlowFixMe,
2323
defaultValue: $FlowFixMe | null,
@@ -219,7 +219,7 @@ function flattenProperties(
219219
}
220220

221221
// $FlowFixMe[unsupported-variance-annotation]
222-
function getTypeAnnotation<out T>(
222+
function getTypeAnnotation<+T>(
223223
name: string,
224224
annotation: $FlowFixMe | ASTNode,
225225
defaultValue: $FlowFixMe | null,

packages/react-native-codegen/src/parsers/parsers-commons.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function wrapModuleSchema(
107107
}
108108

109109
// $FlowFixMe[unsupported-variance-annotation]
110-
function unwrapNullable<out T extends NativeModuleTypeAnnotation>(
110+
function unwrapNullable<+T extends NativeModuleTypeAnnotation>(
111111
x: Nullable<T>,
112112
): [T, boolean] {
113113
if (x.type === 'NullableTypeAnnotation') {
@@ -118,7 +118,7 @@ function unwrapNullable<out T extends NativeModuleTypeAnnotation>(
118118
}
119119

120120
// $FlowFixMe[unsupported-variance-annotation]
121-
function wrapNullable<out T extends NativeModuleTypeAnnotation>(
121+
function wrapNullable<+T extends NativeModuleTypeAnnotation>(
122122
nullable: boolean,
123123
typeAnnotation: T,
124124
): Nullable<T> {

packages/react-native/Libraries/Animated/createAnimatedComponent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type Nullable = void | null;
3131
type Primitive = string | number | boolean | symbol | void;
3232
type Builtin = (...ReadonlyArray<empty>) => unknown | Date | Error | RegExp;
3333

34-
export type WithAnimatedValue<out T> = T extends Builtin | Nullable
34+
export type WithAnimatedValue<+T> = T extends Builtin | Nullable
3535
? T
3636
: T extends Primitive
3737
?
@@ -91,7 +91,7 @@ export type AnimatedBaseProps<Props extends {...}> = LooseOmit<
9191

9292
export type AnimatedComponentType<
9393
Props extends {...},
94-
out Instance = unknown,
94+
+Instance = unknown,
9595
> = component(ref?: React.RefSetter<Instance>, ...AnimatedProps<Props>);
9696

9797
export default function createAnimatedComponent<

packages/react-native/Libraries/StyleSheet/StyleSheet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export type DangerouslyImpreciseStyleProp =
118118
* This will correctly give you the type 'absolute' | 'relative'
119119
*/
120120
export type TypeForStyleKey<
121-
out key extends keyof ____DangerouslyImpreciseStyle_Internal,
121+
+key extends keyof ____DangerouslyImpreciseStyle_Internal,
122122
> = ____DangerouslyImpreciseStyle_Internal[key];
123123

124124
/**

packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export type DangerouslyImpreciseStyleProp =
119119
* This will correctly give you the type 'absolute' | 'relative'
120120
*/
121121
export type TypeForStyleKey<
122-
out key extends keyof ____DangerouslyImpreciseStyle_Internal,
122+
+key extends keyof ____DangerouslyImpreciseStyle_Internal,
123123
> = ____DangerouslyImpreciseStyle_Internal[key];
124124

125125
/**

packages/react-native/Libraries/StyleSheet/StyleSheetExports.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export default {
179179
* An identity function for creating style sheets.
180180
*/
181181
// $FlowFixMe[unsupported-variance-annotation]
182-
create<out S extends ____Styles_Internal>(obj: S): Readonly<S> {
182+
create<+S extends ____Styles_Internal>(obj: S): Readonly<S> {
183183
// TODO: This should return S as the return type. But first,
184184
// we need to codemod all the callsites that are typing this
185185
// return value as a number (even though it was opaque).

packages/react-native/Libraries/StyleSheet/StyleSheetExports.js.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ declare export const setStyleAttributePreprocessor: (
9595
* An identity function for creating style sheets.
9696
*/
9797
// $FlowFixMe[unsupported-variance-annotation]
98-
declare export const create: <out S extends ____Styles_Internal>(
98+
declare export const create: <+S extends ____Styles_Internal>(
9999
obj: S & ____Styles_Internal,
100100
) => Readonly<S>;

packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ export type ____DangerouslyImpreciseStyle_Internal = Readonly<{
10641064
...
10651065
}>;
10661066

1067-
export type StyleProp<out T> =
1067+
export type StyleProp<+T> =
10681068
| null
10691069
| void
10701070
| T
@@ -1100,7 +1100,7 @@ export type ____Styles_Internal = {
11001100
// ____FlattenStyleProp_Helper should be considered internal.
11011101
type FlattenDepthLimiter = [void, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
11021102
type ____FlattenStyleProp_Helper<
1103-
out TStyleProp extends StyleProp<unknown>,
1103+
+TStyleProp extends StyleProp<unknown>,
11041104
Depth extends Values<FlattenDepthLimiter> = 9,
11051105
> = Depth extends 0
11061106
? empty
@@ -1114,7 +1114,7 @@ type ____FlattenStyleProp_Helper<
11141114
: TStyleProp;
11151115

11161116
export type ____FlattenStyleProp_Internal<
1117-
out TStyleProp extends StyleProp<unknown>,
1117+
+TStyleProp extends StyleProp<unknown>,
11181118
> =
11191119
____FlattenStyleProp_Helper<TStyleProp> extends empty // $FlowFixMe[unclear-type]
11201120
? any

packages/react-native/Libraries/Types/CoreEventTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import type {HostInstance} from '../../src/private/types/HostInstance';
1212

13-
export type NativeSyntheticEvent<out T> = Readonly<{
13+
export type NativeSyntheticEvent<+T> = Readonly<{
1414
bubbles: ?boolean,
1515
cancelable: ?boolean,
1616
currentTarget: number | HostInstance,

0 commit comments

Comments
 (0)