mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Transform $ReadOnlyArray to ReadonlyArray 18/n (#55152)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55152 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 Command: `js1 flow-runner codemod flow/transformUtilityType --legacy-type='$ReadOnlyArray'` Reviewed By: SamChou19815 Differential Revision: D90424826 fbshipit-source-id: 207e1abebb50671e8eb2a7f79ecfeaf4569b5b3e
This commit is contained in:
1 parent
7051a07c63
commit
92c32780f1
167 files changed
+416
-417
No files matched your search
@@ -435,8 +435,8 @@ function emitUnion(
|
||||
translateTypeAnnotation: $FlowFixMe,
|
||||
parser: Parser,
|
||||
): Nullable<NativeModuleUnionTypeAnnotation> {
|
||||
const unparsedMemberTypes: $ReadOnlyArray<$FlowFixMe> =
|
||||
(typeAnnotation.types: $ReadOnlyArray<$FlowFixMe>);
|
||||
const unparsedMemberTypes: ReadonlyArray<$FlowFixMe> =
|
||||
(typeAnnotation.types: ReadonlyArray<$FlowFixMe>);
|
||||
|
||||
const memberTypes = unparsedMemberTypes.map(
|
||||
(memberType: $FlowFixMe): NativeModuleUnionTypeAnnotationMemberType => {
|
||||
|
||||
+4
-4
@@ -23,10 +23,10 @@ import type {
|
||||
export type ComponentSchemaBuilderConfig = Readonly<{
|
||||
filename: string,
|
||||
componentName: string,
|
||||
extendsProps: $ReadOnlyArray<ExtendsPropsShape>,
|
||||
events: $ReadOnlyArray<EventTypeShape>,
|
||||
props: $ReadOnlyArray<NamedShape<PropTypeAnnotation>>,
|
||||
commands: $ReadOnlyArray<NamedShape<CommandTypeAnnotation>>,
|
||||
extendsProps: ReadonlyArray<ExtendsPropsShape>,
|
||||
events: ReadonlyArray<EventTypeShape>,
|
||||
props: ReadonlyArray<NamedShape<PropTypeAnnotation>>,
|
||||
commands: ReadonlyArray<NamedShape<CommandTypeAnnotation>>,
|
||||
options?: ?OptionsShape,
|
||||
}>;
|
||||
|
||||
|
||||
+2
-2
@@ -205,10 +205,10 @@ function buildCommandSchema(
|
||||
}
|
||||
|
||||
function getCommands(
|
||||
commandTypeAST: $ReadOnlyArray<EventTypeAST>,
|
||||
commandTypeAST: ReadonlyArray<EventTypeAST>,
|
||||
types: TypeDeclarationMap,
|
||||
parser: Parser,
|
||||
): $ReadOnlyArray<NamedShape<CommandTypeAnnotation>> {
|
||||
): ReadonlyArray<NamedShape<CommandTypeAnnotation>> {
|
||||
return commandTypeAST
|
||||
.filter(
|
||||
property =>
|
||||
|
||||
+2
-2
@@ -476,10 +476,10 @@ function getSchemaInfo(
|
||||
}
|
||||
|
||||
function flattenProperties(
|
||||
typeDefinition: $ReadOnlyArray<PropAST>,
|
||||
typeDefinition: ReadonlyArray<PropAST>,
|
||||
types: TypeDeclarationMap,
|
||||
parser: Parser,
|
||||
): $ReadOnlyArray<PropAST> {
|
||||
): ReadonlyArray<PropAST> {
|
||||
return typeDefinition
|
||||
.map(property => {
|
||||
if (property.type === 'TSPropertySignature') {
|
||||
|
||||
@@ -178,7 +178,7 @@ function findEventArgumentsAndType(
|
||||
bubblingType: void | 'direct' | 'bubble',
|
||||
paperName: ?$FlowFixMe,
|
||||
): {
|
||||
argumentProps: ?$ReadOnlyArray<$FlowFixMe>,
|
||||
argumentProps: ?ReadonlyArray<$FlowFixMe>,
|
||||
paperTopLevelNameDeprecated: ?$FlowFixMe,
|
||||
bubblingType: ?'direct' | 'bubble',
|
||||
} {
|
||||
@@ -280,10 +280,10 @@ function buildEventSchema(
|
||||
}
|
||||
|
||||
function getEvents(
|
||||
eventTypeAST: $ReadOnlyArray<EventTypeAST>,
|
||||
eventTypeAST: ReadonlyArray<EventTypeAST>,
|
||||
types: TypeDeclarationMap,
|
||||
parser: Parser,
|
||||
): $ReadOnlyArray<EventTypeShape> {
|
||||
): ReadonlyArray<EventTypeShape> {
|
||||
return eventTypeAST
|
||||
.map(property => buildEventSchema(types, property, parser))
|
||||
.filter(Boolean);
|
||||
|
||||
@@ -27,7 +27,7 @@ function isEvent(typeAnnotation: $FlowFixMe, parser: Parser): boolean {
|
||||
type PropsAST = Object;
|
||||
|
||||
function categorizeProps(
|
||||
typeDefinition: $ReadOnlyArray<PropsAST>,
|
||||
typeDefinition: ReadonlyArray<PropsAST>,
|
||||
types: TypeDeclarationMap,
|
||||
events: Array<PropsAST>,
|
||||
parser: Parser,
|
||||
|
||||
+2
-4
@@ -35,7 +35,7 @@ type PrimitiveTypeAnnotationType =
|
||||
| 'FloatTypeAnnotation'
|
||||
| 'BooleanTypeAnnotation';
|
||||
|
||||
const PRIMITIVES: $ReadOnlyArray<[string, PrimitiveTypeAnnotationType]> = [
|
||||
const PRIMITIVES: ReadonlyArray<[string, PrimitiveTypeAnnotationType]> = [
|
||||
['string', 'StringTypeAnnotation'],
|
||||
['number', 'NumberTypeAnnotation'],
|
||||
['Int32', 'Int32TypeAnnotation'],
|
||||
@@ -44,9 +44,7 @@ const PRIMITIVES: $ReadOnlyArray<[string, PrimitiveTypeAnnotationType]> = [
|
||||
['boolean', 'BooleanTypeAnnotation'],
|
||||
];
|
||||
|
||||
const RESERVED_FUNCTION_VALUE_TYPE_NAME: $ReadOnlyArray<'RootTag'> = [
|
||||
'RootTag',
|
||||
];
|
||||
const RESERVED_FUNCTION_VALUE_TYPE_NAME: ReadonlyArray<'RootTag'> = ['RootTag'];
|
||||
|
||||
const MODULE_NAME = 'NativeFoo';
|
||||
|
||||
|
||||
@@ -57,9 +57,9 @@ function translateObjectTypeAnnotation(
|
||||
*/
|
||||
typeScriptTypeAnnotation: $FlowFixMe,
|
||||
nullable: boolean,
|
||||
objectMembers: $ReadOnlyArray<$FlowFixMe>,
|
||||
objectMembers: ReadonlyArray<$FlowFixMe>,
|
||||
typeResolutionStatus: TypeResolutionStatus,
|
||||
baseTypes: $ReadOnlyArray<string>,
|
||||
baseTypes: ReadonlyArray<string>,
|
||||
types: TypeDeclarationMap,
|
||||
aliasMap: {...NativeModuleAliasMap},
|
||||
enumMap: {...NativeModuleEnumMap},
|
||||
|
||||
@@ -157,7 +157,7 @@ class TypeScriptParser implements Parser {
|
||||
|
||||
getFunctionTypeAnnotationParameters(
|
||||
functionTypeAnnotation: $FlowFixMe,
|
||||
): $ReadOnlyArray<$FlowFixMe> {
|
||||
): ReadonlyArray<$FlowFixMe> {
|
||||
return functionTypeAnnotation.parameters;
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ class TypeScriptParser implements Parser {
|
||||
|
||||
parseEnumMembers(
|
||||
typeAnnotation: $FlowFixMe,
|
||||
): $ReadOnlyArray<NativeModuleEnumMember> {
|
||||
): ReadonlyArray<NativeModuleEnumMember> {
|
||||
return typeAnnotation.members.map(member => {
|
||||
const value =
|
||||
member.initializer?.operator === '-'
|
||||
@@ -385,7 +385,7 @@ class TypeScriptParser implements Parser {
|
||||
return annotatedElement.typeAnnotation.members;
|
||||
}
|
||||
|
||||
bodyProperties(typeAlias: TypeDeclarationMap): $ReadOnlyArray<$FlowFixMe> {
|
||||
bodyProperties(typeAlias: TypeDeclarationMap): ReadonlyArray<$FlowFixMe> {
|
||||
return typeAlias.body.body;
|
||||
}
|
||||
|
||||
@@ -516,11 +516,11 @@ class TypeScriptParser implements Parser {
|
||||
}
|
||||
|
||||
getProps(
|
||||
typeDefinition: $ReadOnlyArray<PropAST>,
|
||||
typeDefinition: ReadonlyArray<PropAST>,
|
||||
types: TypeDeclarationMap,
|
||||
): {
|
||||
props: $ReadOnlyArray<NamedShape<PropTypeAnnotation>>,
|
||||
extendsProps: $ReadOnlyArray<ExtendsPropsShape>,
|
||||
props: ReadonlyArray<NamedShape<PropTypeAnnotation>>,
|
||||
extendsProps: ReadonlyArray<ExtendsPropsShape>,
|
||||
} {
|
||||
const extendsProps: Array<ExtendsPropsShape> = [];
|
||||
const componentPropAsts: Array<PropAST> = [];
|
||||
|
||||
Reference in new issue
Block a user