Skip to content

Commit 894a1f1

Browse files
marcoww6meta-codesync[bot]
authored andcommitted
Transform mixed to unknown in xplat/js (#54954)
Summary: Pull Request resolved: #54954 We are transforming the following utility types to be more consistent with typescript and better AI integration: * `$NonMaybeType` -> `NonNullable` * `$ReadOnly` -> `Readonly` * `$ReadOnlyArray` -> `ReadonlyArray` * `$ReadOnlyMap` -> `ReadonlyMap` * `$ReadOnlySet` -> `ReadonlySet` * `$Keys` -> `keyof` * `$Values` -> `Values` * `mixed` -> `unknown` See details in https://fb.workplace.com/groups/flowlang/permalink/1837907750148213/. drop-conflicts Reviewed By: SamChou19815 Differential Revision: D89581744 fbshipit-source-id: 58a6c246629bbe4fb5c0af447dc002c48e10c342
1 parent 2624e2f commit 894a1f1

131 files changed

Lines changed: 409 additions & 409 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/react-native-codegen/src/generators/Utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function indent(nice: string, spaces: number): string {
2323
if (line.length === 0 || index === 0) {
2424
return line;
2525
}
26-
const emptySpaces = new Array<mixed>(spaces + 1).join(' ');
26+
const emptySpaces = new Array<unknown>(spaces + 1).join(' ');
2727
return emptySpaces + line;
2828
})
2929
.join('\n');

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function buildCommandSchema(
131131
};
132132
break;
133133
default:
134-
(type: mixed);
134+
(type: unknown);
135135
throw new Error(
136136
`Unsupported param type for method "${name}", param "${paramName}". Found ${type}`,
137137
);
@@ -160,7 +160,7 @@ function buildCommandSchema(
160160
type Allowed = ComponentCommandArrayTypeAnnotation['elementType'];
161161

162162
function getCommandArrayElementTypeType(
163-
inputType: mixed,
163+
inputType: unknown,
164164
parser: Parser,
165165
): Allowed {
166166
// TODO: T172453752 support more complex type annotation for array element

packages/react-native-codegen/src/parsers/typescript/components/commands.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function buildCommandSchemaInternal(
102102
};
103103
break;
104104
default:
105-
(type: mixed);
105+
(type: unknown);
106106
throw new Error(
107107
`Unsupported param type for method "${name}", param "${paramName}". Found ${type}`,
108108
);
@@ -129,7 +129,7 @@ function buildCommandSchemaInternal(
129129
}
130130

131131
function getCommandArrayElementTypeType(
132-
inputType: mixed,
132+
inputType: unknown,
133133
parser: Parser,
134134
): ComponentCommandArrayTypeAnnotation['elementType'] {
135135
// TODO: T172453752 support more complex type annotation for array element

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ function getTypeAnnotationForArray<T>(
335335
type: 'FloatTypeAnnotation',
336336
};
337337
default:
338-
(type: mixed);
338+
(type: unknown);
339339
throw new Error(`Unknown prop type for "${name}": ${type}`);
340340
}
341341
}

packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-props-all-types/NativeComponent.js.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export type Props = $ReadOnly<{
2828
int: Int32,
2929
stringUnion: WithDefault<'foo' | 'bar', 'bar'>,
3030
intUnion: WithDefault<1 | 2, 1>,
31-
mixed: mixed,
31+
mixed: unknown,
3232

3333
backgroundColor?: WithDefault<string, 'transparent'>,
3434
height?: WithDefault<Int32, 100>,

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,47 +88,47 @@ export type PressabilityConfig = $ReadOnly<{
8888
/**
8989
* Called after the element loses focus.
9090
*/
91-
onBlur?: ?(event: BlurEvent) => mixed,
91+
onBlur?: ?(event: BlurEvent) => unknown,
9292

9393
/**
9494
* Called after the element is focused.
9595
*/
96-
onFocus?: ?(event: FocusEvent) => mixed,
96+
onFocus?: ?(event: FocusEvent) => unknown,
9797

9898
/**
9999
* Called when the hover is activated to provide visual feedback.
100100
*/
101-
onHoverIn?: ?(event: MouseEvent) => mixed,
101+
onHoverIn?: ?(event: MouseEvent) => unknown,
102102

103103
/**
104104
* Called when the hover is deactivated to undo visual feedback.
105105
*/
106-
onHoverOut?: ?(event: MouseEvent) => mixed,
106+
onHoverOut?: ?(event: MouseEvent) => unknown,
107107

108108
/**
109109
* Called when a long press gesture has been triggered.
110110
*/
111-
onLongPress?: ?(event: GestureResponderEvent) => mixed,
111+
onLongPress?: ?(event: GestureResponderEvent) => unknown,
112112

113113
/**
114114
* Called when a press gesture has been triggered.
115115
*/
116-
onPress?: ?(event: GestureResponderEvent) => mixed,
116+
onPress?: ?(event: GestureResponderEvent) => unknown,
117117

118118
/**
119119
* Called when the press is activated to provide visual feedback.
120120
*/
121-
onPressIn?: ?(event: GestureResponderEvent) => mixed,
121+
onPressIn?: ?(event: GestureResponderEvent) => unknown,
122122

123123
/**
124124
* Called when the press location moves. (This should rarely be used.)
125125
*/
126-
onPressMove?: ?(event: GestureResponderEvent) => mixed,
126+
onPressMove?: ?(event: GestureResponderEvent) => unknown,
127127

128128
/**
129129
* Called when the press is deactivated to undo visual feedback.
130130
*/
131-
onPressOut?: ?(event: GestureResponderEvent) => mixed,
131+
onPressOut?: ?(event: GestureResponderEvent) => unknown,
132132

133133
/**
134134
* Whether to prevent any other native components from becoming responder

packages/react-native/Libraries/Pressability/__tests__/Pressability-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const itif = (condition: boolean) => {
2626
};
2727

2828
// TODO: Move this util to a shared location.
29-
function getMock<TArguments: $ReadOnlyArray<mixed>, TReturn>(
29+
function getMock<TArguments: $ReadOnlyArray<unknown>, TReturn>(
3030
fn: (...args: TArguments) => TReturn,
3131
): JestMockFn<TArguments, TReturn> {
3232
if (!jest.isMockFunction(fn)) {

packages/react-native/Libraries/ReactNative/AppRegistry.flow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export type AppConfig = {
2929
...
3030
};
3131
export type AppParameters = {
32-
initialProps: $ReadOnly<{[string]: mixed, ...}>,
32+
initialProps: $ReadOnly<{[string]: unknown, ...}>,
3333
rootTag: RootTag,
3434
fabric?: boolean,
3535
};

packages/react-native/Libraries/ReactNative/BridgelessUIManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ const UIManagerJS: UIManagerJSInterface & {[string]: any} = {
265265
...UIManagerJSDeprecatedPlatformAPIs,
266266
...UIManagerJSPlatformAPIs,
267267
...UIManagerJSUnusedInNewArchAPIs,
268-
getViewManagerConfig: (viewManagerName: string): mixed => {
268+
getViewManagerConfig: (viewManagerName: string): unknown => {
269269
if (getUIManagerConstants) {
270270
const constants = getUIManagerConstantsCached();
271271
if (

packages/react-native/Libraries/ReactNative/FabricUIManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export interface Spec {
7171
+dispatchCommand: (
7272
node: Node,
7373
commandName: string,
74-
args: Array<mixed>,
74+
args: Array<unknown>,
7575
) => void;
7676
+findNodeAtPoint: (
7777
node: Node,

0 commit comments

Comments
 (0)