Skip to content

Commit 1cc30dc

Browse files
marcoww6meta-codesync[bot]
authored andcommitted
Transform $ReadOnly to Readonly 37/n (#55066)
Summary: Pull Request resolved: #55066 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='$ReadOnly'` Changelog:[internal] Differential Revision: D90146145 fbshipit-source-id: 4b71784a36f8286f3be620969ea408cf8a0aac80
1 parent 58bc6c3 commit 1cc30dc

File tree

175 files changed

+512
-519
lines changed

Some content is hidden

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

175 files changed

+512
-519
lines changed

flow-typed/environment/node.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ declare module 'buffer' {
199199
declare var kMaxLength: number;
200200
declare var INSPECT_MAX_BYTES: number;
201201

202-
declare var constants: $ReadOnly<{
202+
declare var constants: Readonly<{
203203
MAX_LENGTH: number,
204204
MAX_STRING_LENGTH: number,
205205
}>;
@@ -1467,7 +1467,7 @@ declare module 'fs' {
14671467
path: string,
14681468
options:
14691469
| string
1470-
| $ReadOnly<{
1470+
| Readonly<{
14711471
encoding?: string,
14721472
recursive?: boolean,
14731473
withFileTypes?: false,
@@ -1477,7 +1477,7 @@ declare module 'fs' {
14771477
): void;
14781478
declare function readdir(
14791479
path: string,
1480-
options: $ReadOnly<{
1480+
options: Readonly<{
14811481
encoding?: string,
14821482
recursive?: boolean,
14831483
withFileTypes: true,
@@ -1493,7 +1493,7 @@ declare module 'fs' {
14931493
path: string,
14941494
options?:
14951495
| string
1496-
| $ReadOnly<{
1496+
| Readonly<{
14971497
encoding?: string,
14981498
recursive?: boolean,
14991499
withFileTypes?: false,
@@ -1503,7 +1503,7 @@ declare module 'fs' {
15031503
path: string,
15041504
options?:
15051505
| string
1506-
| $ReadOnly<{
1506+
| Readonly<{
15071507
encoding?: string,
15081508
recursive?: boolean,
15091509
withFileTypes: true,
@@ -1527,13 +1527,13 @@ declare module 'fs' {
15271527
): void;
15281528
declare function openAsBlob(
15291529
path: string | Buffer | URL,
1530-
options?: $ReadOnly<{
1530+
options?: Readonly<{
15311531
type?: string, // Optional MIME type hint
15321532
}>,
15331533
): Promise<Blob>;
15341534
declare function opendir(
15351535
path: string,
1536-
options?: $ReadOnly<{
1536+
options?: Readonly<{
15371537
encoding?: string,
15381538
bufferSize?: number,
15391539
recursive?: boolean,
@@ -1542,7 +1542,7 @@ declare module 'fs' {
15421542
): void;
15431543
declare function opendirSync(
15441544
path: string,
1545-
options?: $ReadOnly<{
1545+
options?: Readonly<{
15461546
encoding?: string,
15471547
bufferSize?: number,
15481548
recursive?: boolean,
@@ -1770,7 +1770,7 @@ declare module 'fs' {
17701770
): void;
17711771
declare function watchFile(
17721772
filename: string,
1773-
options?: $ReadOnly<{
1773+
options?: Readonly<{
17741774
bigint?: boolean,
17751775
persistent?: boolean,
17761776
interval?: number,
@@ -1787,7 +1787,7 @@ declare module 'fs' {
17871787
): FSWatcher;
17881788
declare function watch(
17891789
filename: string,
1790-
options?: $ReadOnly<{
1790+
options?: Readonly<{
17911791
persistent?: boolean,
17921792
recursive?: boolean,
17931793
encoding?: string,
@@ -1835,7 +1835,7 @@ declare module 'fs' {
18351835
declare function cp(
18361836
src: string | URL,
18371837
dest: string | URL,
1838-
options: $ReadOnly<{
1838+
options: Readonly<{
18391839
dereference?: boolean,
18401840
errorOnExist?: boolean,
18411841
filter?: (src: string, dest: string) => boolean | Promise<boolean>,
@@ -1855,7 +1855,7 @@ declare module 'fs' {
18551855
declare function cpSync(
18561856
src: string | URL,
18571857
dest: string | URL,
1858-
options?: $ReadOnly<{
1858+
options?: Readonly<{
18591859
dereference?: boolean,
18601860
errorOnExist?: boolean,
18611861
filter?: (src: string, dest: string) => boolean,
@@ -2022,7 +2022,7 @@ declare module 'fs' {
20222022
chown(uid: number, guid: number): Promise<void>;
20232023
close(): Promise<void>;
20242024
createReadStream(
2025-
options?: $ReadOnly<{
2025+
options?: Readonly<{
20262026
encoding?: string,
20272027
autoClose?: boolean,
20282028
emitClose?: boolean,
@@ -2033,7 +2033,7 @@ declare module 'fs' {
20332033
}>,
20342034
): ReadStream;
20352035
createWriteStream(
2036-
options?: $ReadOnly<{
2036+
options?: Readonly<{
20372037
encoding?: string,
20382038
autoClose?: boolean,
20392039
emitClose?: boolean,
@@ -2055,12 +2055,12 @@ declare module 'fs' {
20552055
...
20562056
}>;
20572057
readableWebStream(
2058-
options?: $ReadOnly<{autoClose?: boolean}>,
2058+
options?: Readonly<{autoClose?: boolean}>,
20592059
): ReadableStream;
20602060
readFile(options: EncodingFlag): Promise<Buffer>;
20612061
readFile(options: string): Promise<string>;
20622062
readLines(
2063-
options?: $ReadOnly<{
2063+
options?: Readonly<{
20642064
encoding?: string,
20652065
autoClose?: boolean,
20662066
emitClose?: boolean,
@@ -2088,7 +2088,7 @@ declare module 'fs' {
20882088
): Promise<void>;
20892089
write(
20902090
buffer: Buffer | Uint8Array | DataView,
2091-
options?: $ReadOnly<{
2091+
options?: Readonly<{
20922092
offset?: number,
20932093
length?: number,
20942094
position?: number,
@@ -2119,7 +2119,7 @@ declare module 'fs' {
21192119
cp(
21202120
src: string | URL,
21212121
dest: string | URL,
2122-
options?: $ReadOnly<{
2122+
options?: Readonly<{
21232123
dereference?: boolean,
21242124
errorOnExist?: boolean,
21252125
filter?: (src: string, dest: string) => boolean | Promise<boolean>,
@@ -2171,7 +2171,7 @@ declare module 'fs' {
21712171
): Promise<FileHandle>,
21722172
opendir(
21732173
path: string,
2174-
options?: $ReadOnly<{
2174+
options?: Readonly<{
21752175
encoding?: string,
21762176
bufferSize?: number,
21772177
recursive?: boolean,
@@ -2192,15 +2192,15 @@ declare module 'fs' {
21922192
path: FSPromisePath,
21932193
options:
21942194
| string
2195-
| $ReadOnly<{
2195+
| Readonly<{
21962196
encoding?: string,
21972197
recursive?: boolean,
21982198
withFileTypes?: false,
21992199
}>,
22002200
) => Promise<Array<string>>) &
22012201
((
22022202
path: FSPromisePath,
2203-
options: $ReadOnly<{
2203+
options: Readonly<{
22042204
encoding?: string,
22052205
recursive?: boolean,
22062206
withFileTypes: true,
@@ -2249,7 +2249,7 @@ declare module 'fs' {
22492249
): Promise<void>,
22502250
watch(
22512251
filename: FSPromisePath,
2252-
options?: $ReadOnly<{
2252+
options?: Readonly<{
22532253
persistent?: boolean,
22542254
recursive?: boolean,
22552255
encoding?: string,

flow-typed/npm/@octokit/rest_v22.x.x.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ declare module '@octokit/rest' {
1313
declare class Octokit {
1414
constructor(options?: {auth?: string, ...}): this;
1515

16-
repos: $ReadOnly<{
16+
repos: Readonly<{
1717
listReleaseAssets: (
18-
params: $ReadOnly<{
18+
params: Readonly<{
1919
owner: string,
2020
repo: string,
2121
release_id: string,
@@ -29,13 +29,13 @@ declare module '@octokit/rest' {
2929
...
3030
}>,
3131
uploadReleaseAsset: (
32-
params: $ReadOnly<{
32+
params: Readonly<{
3333
owner: string,
3434
repo: string,
3535
release_id: string,
3636
name: string,
3737
data: Buffer,
38-
headers: $ReadOnly<{
38+
headers: Readonly<{
3939
'content-type': string,
4040
...
4141
}>,

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ declare module '@babel/traverse' {
9797
/** Traverse node with current scope and path. */
9898
traverse<S>(
9999
node: BabelNode | Array<BabelNode>,
100-
opts: $ReadOnly<TraverseOptions<S>>,
100+
opts: Readonly<TraverseOptions<S>>,
101101
state: S,
102102
): void;
103103

@@ -303,7 +303,7 @@ declare module '@babel/traverse' {
303303
shouldStop: boolean;
304304
removed: boolean;
305305
state: unknown;
306-
+opts: $ReadOnly<TraverseOptions<unknown>> | null;
306+
+opts: Readonly<TraverseOptions<unknown>> | null;
307307
skipKeys: null | {[key: string]: boolean};
308308
parentPath: ?NodePath<>;
309309
context: TraversalContext;
@@ -346,7 +346,7 @@ declare module '@babel/traverse' {
346346
): TError;
347347

348348
traverse<TState>(
349-
visitor: $ReadOnly<TraverseOptions<TState>>,
349+
visitor: Readonly<TraverseOptions<TState>>,
350350
state: TState,
351351
): void;
352352

@@ -1444,7 +1444,7 @@ declare module '@babel/traverse' {
14441444
| VisitNodeFunction<TNode, TState>
14451445
| VisitNodeObject<TNode, TState>;
14461446

1447-
declare export type Visitor<TState = void> = $ReadOnly<{
1447+
declare export type Visitor<TState = void> = Readonly<{
14481448
enter?: VisitNodeFunction<BabelNode, TState>,
14491449
exit?: VisitNodeFunction<BabelNode, TState>,
14501450

@@ -1872,7 +1872,7 @@ declare module '@babel/traverse' {
18721872
explode<TState>(visitor: Visitor<TState>): Visitor<TState>,
18731873
verify<TState>(visitor: Visitor<TState>): void,
18741874
merge(
1875-
visitors: Array<$ReadOnly<Visitor<any>>>,
1875+
visitors: Array<Readonly<Visitor<any>>>,
18761876
states: Array<any>,
18771877
wrapper?: ?Function,
18781878
): Array<Visitor<any>>,
@@ -1891,7 +1891,7 @@ declare module '@babel/traverse' {
18911891
declare export type Traverse = {
18921892
<TState>(
18931893
parent?: BabelNode | Array<BabelNode>,
1894-
opts?: $ReadOnly<TraverseOptions<TState>>,
1894+
opts?: Readonly<TraverseOptions<TState>>,
18951895
scope?: ?Scope,
18961896
state: TState,
18971897
parentPath?: ?NodePath<BabelNode>,
@@ -1909,7 +1909,7 @@ declare module '@babel/traverse' {
19091909

19101910
node<TState>(
19111911
node: BabelNode,
1912-
opts: $ReadOnly<TraverseOptions<TState>>,
1912+
opts: Readonly<TraverseOptions<TState>>,
19131913
scope: Scope,
19141914
state: TState,
19151915
parentPath: NodePath<>,

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

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

1111
'use strict';
1212

13-
type _BabelSourceMap = $ReadOnly<{
13+
type _BabelSourceMap = Readonly<{
1414
file?: string,
1515
mappings: string,
1616
names: Array<string>,
@@ -28,9 +28,9 @@ type _BabelSourceMapSegment = {
2828
...
2929
};
3030

31-
export type BabelSourceLocation = $ReadOnly<{
32-
start: $ReadOnly<{line: number, column: number}>,
33-
end: $ReadOnly<{line: number, column: number}>,
31+
export type BabelSourceLocation = Readonly<{
32+
start: Readonly<{line: number, column: number}>,
33+
end: Readonly<{line: number, column: number}>,
3434
}>;
3535

3636
declare module '@babel/parser' {
@@ -330,7 +330,7 @@ declare module '@babel/core' {
330330

331331
constructor(
332332
options: BabelCoreOptions,
333-
input: $ReadOnly<{ast: BabelNode, code: string, inputMap: any}>,
333+
input: Readonly<{ast: BabelNode, code: string, inputMap: any}>,
334334
): File;
335335

336336
getMetadata(): void;
@@ -1079,7 +1079,7 @@ declare module '@babel/core' {
10791079
declare type ValidatedOptions = BabelCoreOptions;
10801080

10811081
declare class PartialConfig {
1082-
+options: $ReadOnly<ValidatedOptions>;
1082+
+options: Readonly<ValidatedOptions>;
10831083
+babelrc: string | void;
10841084
+babelignore: string | void;
10851085
+config: string | void;

flow-typed/npm/electron-packager_v18.x.x.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ declare module '@electron/packager' {
4646

4747
declare export type OsxUniversalOptions = $FlowFixMe;
4848

49-
declare export type Win32MetadataOptions = $ReadOnly<{
49+
declare export type Win32MetadataOptions = Readonly<{
5050
CompanyName?: string,
5151
FileDescription?: string,
5252
OriginalFilename?: string,

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,25 @@ declare module 'execa' {
9191
(
9292
file: string,
9393
args?: $ReadOnlyArray<string>,
94-
options?: $ReadOnly<Options>,
94+
options?: Readonly<Options>,
9595
): ExecaPromise;
96-
(file: string, options?: $ReadOnly<Options>): ExecaPromise;
96+
(file: string, options?: Readonly<Options>): ExecaPromise;
9797

98-
command(command: string, options?: $ReadOnly<Options>): ExecaPromise;
99-
commandSync(command: string, options?: $ReadOnly<Options>): ExecaPromise;
98+
command(command: string, options?: Readonly<Options>): ExecaPromise;
99+
commandSync(command: string, options?: Readonly<Options>): ExecaPromise;
100100

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

107107
sync(
108108
file: string,
109109
args?: $ReadOnlyArray<string>,
110-
options?: $ReadOnly<SyncOptions>,
110+
options?: Readonly<SyncOptions>,
111111
): SyncResult;
112-
sync(file: string, options?: $ReadOnly<SyncOptions>): SyncResult;
112+
sync(file: string, options?: Readonly<SyncOptions>): SyncResult;
113113
}
114114

115115
declare module.exports: Execa;

flow-typed/npm/jsonc-parser_v2.2.x.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ declare module 'jsonc-parser' {
2222
/**
2323
* The scanner object, representing a JSON scanner at a position in the input string.
2424
*/
25-
export type JSONScanner = $ReadOnly<{
25+
export type JSONScanner = Readonly<{
2626
/**
2727
* Sets the scan position to a new offset. A call to 'scan' is needed to get the first token.
2828
*/
@@ -351,7 +351,7 @@ declare module 'jsonc-parser' {
351351
/**
352352
* Options used by {@linkcode format} when computing the formatting edit operations
353353
*/
354-
export type FormattingOptions = $ReadOnly<{
354+
export type FormattingOptions = Readonly<{
355355
/**
356356
* If indentation is based on spaces (`insertSpaces` = true), the number of spaces that make an indent.
357357
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
declare module 'open' {
1212
import type {ChildProcess} from 'child_process';
1313

14-
declare export type Options = $ReadOnly<{
14+
declare export type Options = Readonly<{
1515
wait?: boolean,
1616
background?: boolean,
1717
newInstance?: boolean,

0 commit comments

Comments
 (0)