Skip to content

Commit ffb42bb

Browse files
marcoww6meta-codesync[bot]
authored andcommitted
Transform $ReadOnlyArray to ReadonlyArray 17/n (#55109)
Summary: Pull Request resolved: #55109 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: D90402950
1 parent f15985f commit ffb42bb

Some content is hidden

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

52 files changed

+186
-193
lines changed

flow-typed/environment/node.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,7 +1887,7 @@ declare module 'fs' {
18871887
*/
18881888
exclude?:
18891889
| ((fileName: Node$Conditional<WithFileTypes, Dirent, string>) => boolean)
1890-
| $ReadOnlyArray<string>,
1890+
| ReadonlyArray<string>,
18911891
...
18921892
}>;
18931893

@@ -1905,12 +1905,12 @@ declare module 'fs' {
19051905
* @since v22.0.0
19061906
*/
19071907
declare function glob(
1908-
pattern: string | $ReadOnlyArray<string>,
1908+
pattern: string | ReadonlyArray<string>,
19091909
callback: (err: ?ErrnoError, matches: Array<string>) => void,
19101910
): void;
19111911

19121912
declare function glob<WithFileTypes: boolean = false>(
1913-
pattern: string | $ReadOnlyArray<string>,
1913+
pattern: string | ReadonlyArray<string>,
19141914
options: GlobOptions<WithFileTypes>,
19151915
callback: (
19161916
err: ?ErrnoError,
@@ -1928,7 +1928,7 @@ declare module 'fs' {
19281928
* @returns paths of files that match the pattern.
19291929
*/
19301930
declare function globSync<WithFileTypes: boolean = false>(
1931-
pattern: string | $ReadOnlyArray<string>,
1931+
pattern: string | ReadonlyArray<string>,
19321932
options?: GlobOptions<WithFileTypes>,
19331933
): Node$Conditional<WithFileTypes, Array<Dirent>, Array<string>>;
19341934

@@ -2142,7 +2142,7 @@ declare module 'fs' {
21422142
mtime: number | string | Date,
21432143
): Promise<void>,
21442144
glob<WithFileTypes: boolean = false>(
2145-
pattern: string | $ReadOnlyArray<string>,
2145+
pattern: string | ReadonlyArray<string>,
21462146
options?: GlobOptions<WithFileTypes>,
21472147
): Node$Conditional<
21482148
WithFileTypes,
@@ -2292,7 +2292,7 @@ declare class http$Agent<+SocketT = net$Socket> {
22922292
constructor(options: http$agentOptions): void;
22932293
destroy(): void;
22942294
// $FlowFixMe[incompatible-variance]
2295-
freeSockets: {[name: string]: $ReadOnlyArray<SocketT>, ...};
2295+
freeSockets: {[name: string]: ReadonlyArray<SocketT>, ...};
22962296
getName(options: {
22972297
host: string,
22982298
port: number,
@@ -2302,9 +2302,9 @@ declare class http$Agent<+SocketT = net$Socket> {
23022302
maxFreeSockets: number;
23032303
maxSockets: number;
23042304
// $FlowFixMe[incompatible-variance]
2305-
requests: {[name: string]: $ReadOnlyArray<http$ClientRequest<SocketT>>, ...};
2305+
requests: {[name: string]: ReadonlyArray<http$ClientRequest<SocketT>>, ...};
23062306
// $FlowFixMe[incompatible-variance]
2307-
sockets: {[name: string]: $ReadOnlyArray<SocketT>, ...};
2307+
sockets: {[name: string]: ReadonlyArray<SocketT>, ...};
23082308
}
23092309

23102310
declare class http$IncomingMessage<SocketT = net$Socket>
@@ -2968,11 +2968,11 @@ declare module 'perf_hooks' {
29682968
) => void;
29692969

29702970
declare export class PerformanceObserver {
2971-
static supportedEntryTypes: $ReadOnlyArray<EntryType>;
2971+
static supportedEntryTypes: ReadonlyArray<EntryType>;
29722972
constructor(callback: PerformanceObserverCallback): this;
29732973
observe(
29742974
options: Readonly<{
2975-
entryTypes?: $ReadOnlyArray<EntryType>,
2975+
entryTypes?: ReadonlyArray<EntryType>,
29762976
type?: EntryType,
29772977
buffered?: boolean,
29782978
}>,
@@ -3461,7 +3461,7 @@ declare module 'stream' {
34613461
options?: StreamPipelineOptions,
34623462
): Promise<void>,
34633463
pipeline(
3464-
streams: $ReadOnlyArray<stream$Stream>,
3464+
streams: ReadonlyArray<stream$Stream>,
34653465
options?: StreamPipelineOptions,
34663466
): Promise<void>,
34673467
...
@@ -3900,7 +3900,7 @@ declare module 'url' {
39003900
};
39013901

39023902
declare type url$URLPatternResult = {
3903-
inputs: $ReadOnlyArray<string | url$URLPatternInit>,
3903+
inputs: ReadonlyArray<string | url$URLPatternInit>,
39043904
protocol: url$URLPatternComponentResult,
39053905
username: url$URLPatternComponentResult,
39063906
password: url$URLPatternComponentResult,
@@ -4104,8 +4104,8 @@ declare module 'util' {
41044104

41054105
declare type util$DiffEntry = [operation: -1 | 0 | 1, value: string];
41064106
declare function diff(
4107-
actual: string | $ReadOnlyArray<string>,
4108-
expected: string | $ReadOnlyArray<string>,
4107+
actual: string | ReadonlyArray<string>,
4108+
expected: string | ReadonlyArray<string>,
41094109
): Array<util$DiffEntry>;
41104110

41114111
declare function getSystemErrorMessage(err: number): string;
@@ -4224,7 +4224,7 @@ declare module 'util' {
42244224
| ForegroundColors
42254225
| BackgroundColors
42264226
| Modifiers
4227-
| $ReadOnlyArray<ForegroundColors | BackgroundColors | Modifiers>,
4227+
| ReadonlyArray<ForegroundColors | BackgroundColors | Modifiers>,
42284228
text: string,
42294229
options?: Readonly<{
42304230
stream?: ?stream$Stream,

flow-typed/npm/@expo/spawn-async_v1.x.x.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ declare module '@expo/spawn-async' {
3838

3939
declare function spawnAsync(
4040
command: string,
41-
args?: $ReadOnlyArray<string>,
41+
args?: ReadonlyArray<string>,
4242
options?: SpawnOptions,
4343
): SpawnPromise<SpawnResult>;
4444

flow-typed/npm/@react-native-community/cli-server-api_v19.x.x.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ declare module '@react-native-community/cli-server-api' {
1313

1414
declare type MiddlewareOptions = {
1515
host?: string,
16-
watchFolders: $ReadOnlyArray<string>,
16+
watchFolders: ReadonlyArray<string>,
1717
port: number,
1818
};
1919

flow-typed/npm/babel-traverse_v7.x.x.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,17 +390,15 @@ declare module '@babel/traverse' {
390390
* Earliest is defined as being "before" all the other nodes in terms of list container
391391
* position and visiting key.
392392
*/
393-
getEarliestCommonAncestorFrom(
394-
paths: $ReadOnlyArray<NodePath<>>,
395-
): NodePath<>;
393+
getEarliestCommonAncestorFrom(paths: ReadonlyArray<NodePath<>>): NodePath<>;
396394

397395
/**
398396
* Get the earliest path in the tree where the provided `paths` intersect.
399397
*
400398
* TODO: Possible optimisation target.
401399
*/
402400
getDeepestCommonAncestorFrom(
403-
paths: $ReadOnlyArray<NodePath<>>,
401+
paths: ReadonlyArray<NodePath<>>,
404402
filter?: (
405403
lastCommon: BabelNode,
406404
lastCommonIndex: number,

flow-typed/npm/babel_v7.x.x.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ declare module '@babel/core' {
10271027
declare export var template: Template;
10281028
declare export var traverse: Traverse;
10291029
declare export var types: Types;
1030-
declare export var DEFAULT_EXTENSIONS: $ReadOnlyArray<string>;
1030+
declare export var DEFAULT_EXTENSIONS: ReadonlyArray<string>;
10311031

10321032
declare export function buildExternalHelpers(
10331033
whitelist?: Array<string>,

flow-typed/npm/execa_v5.x.x.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ declare module 'execa' {
3737
shell?: boolean | string,
3838
stderr?: ?StdIoOption,
3939
stdin?: ?StdIoOption,
40-
stdio?: 'pipe' | 'ignore' | 'inherit' | $ReadOnlyArray<?StdIoOption>,
40+
stdio?: 'pipe' | 'ignore' | 'inherit' | ReadonlyArray<?StdIoOption>,
4141
stdout?: ?StdIoOption,
4242
stripEof?: boolean,
4343
timeout?: number,
@@ -90,7 +90,7 @@ declare module 'execa' {
9090
declare interface Execa {
9191
(
9292
file: string,
93-
args?: $ReadOnlyArray<string>,
93+
args?: ReadonlyArray<string>,
9494
options?: Readonly<Options>,
9595
): ExecaPromise;
9696
(file: string, options?: Readonly<Options>): ExecaPromise;
@@ -100,13 +100,13 @@ declare module 'execa' {
100100

101101
node(
102102
path: string,
103-
args?: $ReadOnlyArray<string>,
103+
args?: ReadonlyArray<string>,
104104
options?: Readonly<Options>,
105105
): void;
106106

107107
sync(
108108
file: string,
109-
args?: $ReadOnlyArray<string>,
109+
args?: ReadonlyArray<string>,
110110
options?: Readonly<SyncOptions>,
111111
): SyncResult;
112112
sync(file: string, options?: Readonly<SyncOptions>): SyncResult;

flow-typed/npm/jest.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
// MODIFIED: Added ESLint suppression comment - no-unused-vars doesn't understand declaration files
1515

16-
type JestMockFn<TArguments: $ReadOnlyArray<unknown>, TReturn> = {
16+
type JestMockFn<TArguments: ReadonlyArray<unknown>, TReturn> = {
1717
(...args: TArguments): TReturn,
1818
/**
1919
* An object for introspecting mock calls
@@ -768,7 +768,7 @@ interface JestExpectType {
768768
/**
769769
*
770770
*/
771-
toHaveProperty(propPath: string | $ReadOnlyArray<string>, value?: any): void;
771+
toHaveProperty(propPath: string | ReadonlyArray<string>, value?: any): void;
772772
/**
773773
* Use .toMatch to check that a string matches a regular expression or string.
774774
*/
@@ -881,7 +881,7 @@ type JestObjectType = {
881881
* implementation.
882882
*/
883883
// MODIFIED: Added defaults to type arguments.
884-
fn<TArguments: $ReadOnlyArray<unknown> = $ReadOnlyArray<any>, TReturn = any>(
884+
fn<TArguments: ReadonlyArray<unknown> = ReadonlyArray<any>, TReturn = any>(
885885
implementation?: (...args: TArguments) => TReturn,
886886
): JestMockFn<TArguments, TReturn>,
887887
/**
@@ -1045,11 +1045,11 @@ declare var describe: {
10451045
*/
10461046
each(
10471047
...table:
1048-
| $ReadOnlyArray<$ReadOnlyArray<unknown> | unknown>
1049-
| [$ReadOnlyArray<string>, string]
1048+
| ReadonlyArray<ReadonlyArray<unknown> | unknown>
1049+
| [ReadonlyArray<string>, string]
10501050
): (
10511051
name: JestTestName,
1052-
fn?: (...args: $ReadOnlyArray<any>) => ?Promise<unknown>,
1052+
fn?: (...args: ReadonlyArray<any>) => ?Promise<unknown>,
10531053
timeout?: number,
10541054
) => void,
10551055
...
@@ -1136,8 +1136,8 @@ declare var it: {
11361136
*/
11371137
each(
11381138
...table:
1139-
| $ReadOnlyArray<$ReadOnlyArray<unknown> | unknown>
1140-
| [$ReadOnlyArray<string>, string]
1139+
| ReadonlyArray<ReadonlyArray<unknown> | unknown>
1140+
| [ReadonlyArray<string>, string]
11411141
): (
11421142
name: JestTestName,
11431143
fn?: (...args: Array<any>) => ?Promise<unknown>,
@@ -1252,13 +1252,13 @@ declare var expect: {
12521252
any(value: unknown): JestAsymmetricEqualityType,
12531253
anything(): any,
12541254
// MODIFIED: Array -> $ReadOnlyArray
1255-
arrayContaining(value: $ReadOnlyArray<unknown>): Array<unknown>,
1255+
arrayContaining(value: ReadonlyArray<unknown>): Array<unknown>,
12561256
objectContaining(value: Object): Object,
12571257
/** Matches any received string that contains the exact expected string. */
12581258
stringContaining(value: string): string,
12591259
stringMatching(value: string | RegExp): string,
12601260
not: {
1261-
arrayContaining: (value: $ReadOnlyArray<unknown>) => Array<unknown>,
1261+
arrayContaining: (value: ReadonlyArray<unknown>) => Array<unknown>,
12621262
objectContaining: (value: {...}) => Object,
12631263
stringContaining: (value: string) => string,
12641264
stringMatching: (value: string | RegExp) => string,

flow-typed/npm/listr2_v8.x.x.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ declare module 'listr2' {
5555
options?: Options,
5656
): void;
5757
add<ReturnT>(task: TaskSpec<ContextT, ReturnT>): this;
58-
add<ReturnT>(tasks: $ReadOnlyArray<TaskSpec<ContextT, ReturnT>>): this;
58+
add<ReturnT>(tasks: ReadonlyArray<TaskSpec<ContextT, ReturnT>>): this;
5959
run(ctx?: ContextT): Promise<ContextT>;
6060
}
6161
}

flow-typed/npm/listr_v14.x.x.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ declare module 'listr' {
5555
options?: Options,
5656
): void;
5757
add<ReturnT>(task: TaskSpec<ContextT, ReturnT>): this;
58-
add<ReturnT>(tasks: $ReadOnlyArray<TaskSpec<ContextT, ReturnT>>): this;
58+
add<ReturnT>(tasks: ReadonlyArray<TaskSpec<ContextT, ReturnT>>): this;
5959
run(ctx?: ContextT): Promise<ContextT>;
6060
}
6161
}

packages/community-cli-plugin/src/commands/bundle/assetCatalogIOS.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type ImageSet = {
3131
export function getImageSet(
3232
catalogDir: string,
3333
asset: AssetData,
34-
scales: $ReadOnlyArray<number>,
34+
scales: ReadonlyArray<number>,
3535
): ImageSet {
3636
const fileName = assetPathUtils.getResourceIdentifier(asset);
3737
return {

0 commit comments

Comments
 (0)