Skip to content

Commit 088a919

Browse files
marcoww6facebook-github-bot
authored andcommitted
transformTypeParamBound codemod 9/9
Summary: js1 flow-runner codemod flow/transformTypeParamBound --format-files=false xplat/js Reviewed By: SamChou19815 Differential Revision: D95429551
1 parent d0fe56f commit 088a919

10 files changed

Lines changed: 18 additions & 18 deletions

File tree

packages/react-native/src/private/featureflags/ReactNativeFeatureFlagsBase.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export type OverridesFor<T> = Partial<{
3030
[key in keyof T]: Getter<?ReturnType<T[key]>>,
3131
}>;
3232

33-
function createGetter<T: boolean | number | string>(
33+
function createGetter<T extends boolean | number | string>(
3434
configName: string,
3535
customValueGetter: Getter<?T>,
3636
defaultValue: T,
@@ -52,7 +52,7 @@ function createGetter<T: boolean | number | string>(
5252
}
5353

5454
export function createJavaScriptFlagGetter<
55-
K: keyof ReactNativeFeatureFlagsJsOnly,
55+
K extends keyof ReactNativeFeatureFlagsJsOnly,
5656
>(
5757
configName: K,
5858
defaultValue: ReturnType<ReactNativeFeatureFlagsJsOnly[K]>,
@@ -69,7 +69,7 @@ export function createJavaScriptFlagGetter<
6969

7070
type NativeFeatureFlags = NonNullable<typeof NativeReactNativeFeatureFlags>;
7171

72-
export function createNativeFlagGetter<K: keyof NativeFeatureFlags>(
72+
export function createNativeFlagGetter<K extends keyof NativeFeatureFlags>(
7373
configName: K,
7474
defaultValue: ReturnType<NonNullable<NativeFeatureFlags[K]>>,
7575
skipUnavailableNativeModuleError: boolean = false,

packages/react-native/src/private/styles/composeStyles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* If either style is null or undefined, the other one is returned without
1414
* allocating an array, saving allocations and enabling memoization.
1515
*/
16-
export default function composeStyles<T, U: T, V: T>(
16+
export default function composeStyles<T, U extends T, V extends T>(
1717
style1: ?U,
1818
style2: ?V,
1919
): ?(T | ReadonlyArray<T>) {

packages/react-native/src/private/types/HostComponent.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 './HostInstance';
1212

13-
export type HostComponent<Config: {...}> = component(
13+
export type HostComponent<Config extends {...}> = component(
1414
ref?: React.RefSetter<HostInstance>,
1515
...Config
1616
);

packages/react-native/src/private/webapis/structuredClone/structuredClone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export default function structuredClone<T>(value: T): T {
217217

218218
const NON_SERIALIZABLE_OBJECT_KEY = Symbol('nonSerializableObject');
219219

220-
function isNonSerializableObject<T: interface {}>(obj: T): boolean {
220+
function isNonSerializableObject<T extends interface {}>(obj: T): boolean {
221221
// $FlowExpectedError[invalid-in-lhs]
222222
return NON_SERIALIZABLE_OBJECT_KEY in obj;
223223
}

packages/react-native/src/private/webapis/webidl/PlatformObjects.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ const CLONE_PLATFORM_OBJECT_KEY = Symbol('clonePlatformObject');
1717
* Optionally, it sets the clone function for that platform object, which is a
1818
* simplification of the serializable attribute of the Web interface.
1919
*/
20-
export const setPlatformObject: (<T: interface {}>(
20+
export const setPlatformObject: (<T extends interface {}>(
2121
obj: Class<T>,
2222
options?: {clone: T => T},
2323
) => void) &
24-
(<T: interface {}>(obj: T, options?: {clone: T => T}) => void) =
24+
(<T extends interface {}>(obj: T, options?: {clone: T => T}) => void) =
2525
function setPlatformObject(obj, options) {
2626
if (typeof obj === 'function') {
2727
// $FlowExpectedError[prop-missing]
@@ -43,15 +43,15 @@ export const setPlatformObject: (<T: interface {}>(
4343
/**
4444
* Indicates if the given object is a platform object.
4545
*/
46-
export function isPlatformObject<T: interface {}>(obj: T): boolean {
46+
export function isPlatformObject<T extends interface {}>(obj: T): boolean {
4747
// $FlowExpectedError[invalid-in-lhs]
4848
return IS_PLATFORM_OBJECT_KEY in obj;
4949
}
5050

5151
/**
5252
* Returns the clone function for the given platform object, if it was set.
5353
*/
54-
export function getPlatformObjectClone<T: interface {}>(
54+
export function getPlatformObjectClone<T extends interface {}>(
5555
obj: T,
5656
): (T => T) | void {
5757
// $FlowExpectedError[prop-missing]

packages/rn-tester/js/examples/Touchable/TouchableExample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ class TouchableHitSlop extends React.Component<{...}, $FlowFixMe> {
310310
}
311311

312312
function TouchableNativeMethodChecker<
313-
T: component(ref?: React.RefSetter<any>, ...any),
313+
T extends component(ref?: React.RefSetter<any>, ...any),
314314
>(props: {Component: T, name: string}): React.Node {
315315
const [status, setStatus] = useState<?boolean>(null);
316316
const ref = useRef<any>(null);

packages/virtualized-lists/Lists/StateSafePureComponent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import * as React from 'react';
2222
*/
2323
export default class StateSafePureComponent<
2424
Props,
25-
State: interface {},
25+
State extends interface {},
2626
> extends React.PureComponent<Props, State> {
2727
_inAsyncStateUpdate = false;
2828

@@ -32,7 +32,7 @@ export default class StateSafePureComponent<
3232
}
3333

3434
// $FlowFixMe[incompatible-type]
35-
setState<K: keyof State>(
35+
setState<K extends keyof State>(
3636
partialState: ?(Pick<State, K> | ((State, Props) => ?Pick<State, K>)),
3737
callback?: () => unknown,
3838
): void {

packages/virtualized-lists/Lists/VirtualizedSectionList.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ type State = {childProps: VirtualizedListProps, ...};
131131
*/
132132
class VirtualizedSectionList<
133133
ItemT,
134-
SectionT: SectionBase<
134+
SectionT extends SectionBase<
135135
ItemT,
136136
DefaultVirtualizedSectionT,
137137
> = DefaultVirtualizedSectionT,
@@ -643,7 +643,7 @@ function ItemWithSeparator<ItemT>(
643643

644644
const VirtualizedSectionListComponent = VirtualizedSectionList as component<
645645
ItemT,
646-
SectionT: SectionBase<
646+
SectionT extends SectionBase<
647647
ItemT,
648648
DefaultVirtualizedSectionT,
649649
> = DefaultVirtualizedSectionT,

private/react-native-fantom/runner/getFantomTestConfigs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ function getConfigurationVariations(
485485
return results;
486486
}
487487

488-
function parseFeatureFlagValue<T: boolean | number | string>(
488+
function parseFeatureFlagValue<T extends boolean | number | string>(
489489
defaultValue: T,
490490
value: string,
491491
): T {

private/react-native-fantom/runtime/mocks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const MOCK_FN_TAG: symbol = Symbol('mock function');
1212

1313
// The type is defined this way because if we get a mixed value, we return
1414
// a generic mock function, and if we get a typed function, we get a typed mock.
15-
export const ensureMockFunction: (<TArgs: Array<unknown>, TReturn>(
15+
export const ensureMockFunction: (<TArgs extends Array<unknown>, TReturn>(
1616
fn: (...TArgs) => TReturn,
1717
) => JestMockFn<TArgs, TReturn>) &
1818
((fn: unknown) => JestMockFn<Array<unknown>, unknown>) = fn => {
@@ -29,7 +29,7 @@ export const ensureMockFunction: (<TArgs: Array<unknown>, TReturn>(
2929
return fn;
3030
};
3131

32-
export function createMockFunction<TArgs: Array<unknown>, TReturn>(
32+
export function createMockFunction<TArgs extends Array<unknown>, TReturn>(
3333
initialImplementation?: (...TArgs) => TReturn,
3434
): JestMockFn<TArgs, TReturn> {
3535
let implementation: ?(...TArgs) => TReturn = initialImplementation;

0 commit comments

Comments
 (0)