Skip to content

Commit 53cd9ce

Browse files
marcoww6meta-codesync[bot]
authored andcommitted
transformTypeParamBound codemod 9/9 (#55948)
Summary: X-link: facebook/metro#1665 Pull Request resolved: #55948 js1 flow-runner codemod flow/transformTypeParamBound --format-files=false xplat/js Changelog: [Internal] Reviewed By: SamChou19815 Differential Revision: D95429551 fbshipit-source-id: 6f5694fed74364c6f1c58e28376c86eae6201366
1 parent 48b6f2d commit 53cd9ce

File tree

17 files changed

+92
-82
lines changed

17 files changed

+92
-82
lines changed

flow-typed/environment/node.js

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface ErrnoError extends Error {
2121
syscall?: string;
2222
}
2323

24-
type Node$Conditional<T: boolean, IfTrue, IfFalse> = T extends true
24+
type Node$Conditional<T extends boolean, IfTrue, IfFalse> = T extends true
2525
? IfTrue
2626
: T extends false
2727
? IfFalse
@@ -282,7 +282,7 @@ type child_process$execFileOpts = Readonly<{
282282
signal?: AbortSignal,
283283
}>;
284284

285-
type child_process$execFileCallback<T: string | Buffer> =
285+
type child_process$execFileCallback<T extends string | Buffer> =
286286
child_process$execCallback<T>;
287287

288288
type child_process$execFileSyncOpts = Readonly<{
@@ -414,7 +414,7 @@ type child_process$spawnOpts = Readonly<{
414414
serialization?: 'json' | 'advanced',
415415
}>;
416416

417-
type child_process$spawnSyncRet<T: string | Buffer> = Readonly<{
417+
type child_process$spawnSyncRet<T extends string | Buffer> = Readonly<{
418418
pid: number,
419419
output: Array<any>,
420420
// TODO: subprocess.stdout may be null in case of error
@@ -454,9 +454,9 @@ type child_process$Serializable =
454454
type child_process$SendHandle = net$Server | net$Socket;
455455

456456
declare class child_process$ChildProcessTyped<
457-
TStdin: stream$Writable | null,
458-
TStdout: stream$Readable | null,
459-
TStderr: stream$Readable | null,
457+
TStdin extends stream$Writable | null,
458+
TStdout extends stream$Readable | null,
459+
TStderr extends stream$Readable | null,
460460
> extends events$EventEmitter
461461
{
462462
+stdin: TStdin;
@@ -515,7 +515,7 @@ declare module 'child_process' {
515515
stream$Readable,
516516
>;
517517

518-
type StringOrBuffer<Opts, Default: string | Buffer> =
518+
type StringOrBuffer<Opts, Default extends string | Buffer> =
519519
Opts extends Readonly<{encoding: infer E, ...}>
520520
? E extends buffer$NonBufferEncoding
521521
? string
@@ -524,11 +524,15 @@ declare module 'child_process' {
524524
: string | Buffer
525525
: Default;
526526

527-
type StreamForChannel<Channel: 0 | 1 | 2> = Channel extends 0
527+
type StreamForChannel<Channel extends 0 | 1 | 2> = Channel extends 0
528528
? stream$Writable
529529
: stream$Readable;
530530

531-
type MaybeStream<Opts, FD: 0 | 1 | 2, PipeByDefault: true | false = true> =
531+
type MaybeStream<
532+
Opts,
533+
FD extends 0 | 1 | 2,
534+
PipeByDefault extends true | false = true,
535+
> =
532536
Opts extends Readonly<{stdio: infer E, ...}>
533537
? E extends child_process$StdioPipe
534538
? StreamForChannel<FD>
@@ -552,7 +556,7 @@ declare module 'child_process' {
552556
stream$Readable,
553557
>;
554558

555-
declare function exec<Opts: child_process$execOpts>(
559+
declare function exec<Opts extends child_process$execOpts>(
556560
command: string,
557561
options: Opts,
558562
callback?: child_process$execCallback<StringOrBuffer<Opts, string>>,
@@ -562,11 +566,11 @@ declare module 'child_process' {
562566
stream$Readable,
563567
>;
564568

565-
declare function execSync<Opts: child_process$execSyncOpts>(
569+
declare function execSync<Opts extends child_process$execSyncOpts>(
566570
command: string,
567571
): Buffer;
568572

569-
declare function execSync<Opts: child_process$execSyncOpts>(
573+
declare function execSync<Opts extends child_process$execSyncOpts>(
570574
command: string,
571575
options: Opts,
572576
): StringOrBuffer<Opts, Buffer>;
@@ -583,7 +587,7 @@ declare module 'child_process' {
583587
stream$Readable,
584588
>;
585589

586-
declare function execFile<Opts: child_process$execFileOpts>(
590+
declare function execFile<Opts extends child_process$execFileOpts>(
587591
file: string,
588592
args: ReadonlyArray<string>,
589593
options: Opts,
@@ -594,7 +598,7 @@ declare module 'child_process' {
594598
stream$Readable,
595599
>;
596600

597-
declare function execFile<Opts: child_process$execFileOpts>(
601+
declare function execFile<Opts extends child_process$execFileOpts>(
598602
file: string,
599603
options: Opts,
600604
callback?: child_process$execFileCallback<StringOrBuffer<Opts, string>>,
@@ -609,13 +613,13 @@ declare module 'child_process' {
609613
args?: ReadonlyArray<string>,
610614
): Buffer;
611615

612-
declare function execFileSync<Opts: child_process$execFileSyncOpts>(
616+
declare function execFileSync<Opts extends child_process$execFileSyncOpts>(
613617
command: string,
614618
args: ReadonlyArray<string>,
615619
options: Opts,
616620
): StringOrBuffer<Opts, Buffer>;
617621

618-
declare function execFileSync<Opts: child_process$execFileSyncOpts>(
622+
declare function execFileSync<Opts extends child_process$execFileSyncOpts>(
619623
command: string,
620624
options: Opts,
621625
): StringOrBuffer<Opts, Buffer>;
@@ -625,7 +629,7 @@ declare module 'child_process' {
625629
args?: ReadonlyArray<string>,
626630
): child_process$ChildProcessTyped<null, null, null>;
627631

628-
declare function fork<Opts: child_process$forkOpts>(
632+
declare function fork<Opts extends child_process$forkOpts>(
629633
modulePath: string,
630634
args: ReadonlyArray<string>,
631635
options: Opts,
@@ -635,7 +639,7 @@ declare module 'child_process' {
635639
MaybeStream<Opts, 2, false>,
636640
>;
637641

638-
declare function fork<Opts: child_process$forkOpts>(
642+
declare function fork<Opts extends child_process$forkOpts>(
639643
modulePath: string,
640644
options: Opts,
641645
): child_process$ChildProcessTyped<
@@ -653,7 +657,7 @@ declare module 'child_process' {
653657
stream$Readable,
654658
>;
655659

656-
declare function spawn<Opts: child_process$spawnOpts>(
660+
declare function spawn<Opts extends child_process$spawnOpts>(
657661
command: string,
658662
args: ReadonlyArray<string>,
659663
options: Opts,
@@ -663,7 +667,7 @@ declare module 'child_process' {
663667
MaybeStream<Opts, 2>,
664668
>;
665669

666-
declare function spawn<Opts: child_process$spawnOpts>(
670+
declare function spawn<Opts extends child_process$spawnOpts>(
667671
command: string,
668672
options: Opts,
669673
): child_process$ChildProcessTyped<
@@ -677,13 +681,13 @@ declare module 'child_process' {
677681
args?: ReadonlyArray<string>,
678682
): child_process$spawnSyncRet<Buffer>;
679683

680-
declare function spawnSync<Opts: child_process$spawnSyncOpts>(
684+
declare function spawnSync<Opts extends child_process$spawnSyncOpts>(
681685
command: string,
682686
args: ReadonlyArray<string>,
683687
options: Opts,
684688
): child_process$spawnSyncRet<StringOrBuffer<Opts, Buffer>>;
685689

686-
declare function spawnSync<Opts: child_process$spawnSyncOpts>(
690+
declare function spawnSync<Opts extends child_process$spawnSyncOpts>(
687691
command: string,
688692
options: Opts,
689693
): child_process$spawnSyncRet<StringOrBuffer<Opts, Buffer>>;
@@ -2112,7 +2116,7 @@ declare module 'fs' {
21122116
}>,
21132117
): void;
21142118

2115-
declare type GlobOptions<WithFileTypes: boolean> = Readonly<{
2119+
declare type GlobOptions<WithFileTypes extends boolean> = Readonly<{
21162120
/**
21172121
* Current working directory.
21182122
* @default process.cwd()
@@ -2154,7 +2158,7 @@ declare module 'fs' {
21542158
callback: (err: ?ErrnoError, matches: Array<string>) => void,
21552159
): void;
21562160

2157-
declare function glob<WithFileTypes: boolean = false>(
2161+
declare function glob<WithFileTypes extends boolean = false>(
21582162
pattern: string | ReadonlyArray<string>,
21592163
options: GlobOptions<WithFileTypes>,
21602164
callback: (
@@ -2172,7 +2176,7 @@ declare module 'fs' {
21722176
* @since v22.0.0
21732177
* @returns paths of files that match the pattern.
21742178
*/
2175-
declare function globSync<WithFileTypes: boolean = false>(
2179+
declare function globSync<WithFileTypes extends boolean = false>(
21762180
pattern: string | ReadonlyArray<string>,
21772181
options?: GlobOptions<WithFileTypes>,
21782182
): Node$Conditional<WithFileTypes, Array<Dirent>, Array<string>>;
@@ -2289,7 +2293,7 @@ declare module 'fs' {
22892293
): WriteStream;
22902294
datasync(): Promise<void>;
22912295
fd: number;
2292-
read<T: Buffer | Uint8Array>(
2296+
read<T extends Buffer | Uint8Array>(
22932297
buffer: T,
22942298
offset: number,
22952299
length: number,
@@ -2314,7 +2318,7 @@ declare module 'fs' {
23142318
highWaterMark?: number,
23152319
}>,
23162320
): readline$Interface;
2317-
readv<T: Array<Buffer> | Array<Uint8Array> | Array<DataView>>(
2321+
readv<T extends Array<Buffer> | Array<Uint8Array> | Array<DataView>>(
23182322
buffers: T,
23192323
position?: number | null,
23202324
): Promise<{buffers: T, bytesRead: number}>;
@@ -2340,7 +2344,7 @@ declare module 'fs' {
23402344
}>,
23412345
): Promise<void>;
23422346
writeFile: AppendOrWriteToFileHandle;
2343-
writev<T: Array<Buffer> | Array<Uint8Array> | Array<DataView>>(
2347+
writev<T extends Array<Buffer> | Array<Uint8Array> | Array<DataView>>(
23442348
buffers: T,
23452349
position?: number | null,
23462350
): Promise<{buffers: T, bytesWritten: number}>;
@@ -2386,7 +2390,7 @@ declare module 'fs' {
23862390
atime: number | string | Date,
23872391
mtime: number | string | Date,
23882392
): Promise<void>,
2389-
glob<WithFileTypes: boolean = false>(
2393+
glob<WithFileTypes extends boolean = false>(
23902394
pattern: string | ReadonlyArray<string>,
23912395
options?: GlobOptions<WithFileTypes>,
23922396
): Node$Conditional<
@@ -2422,7 +2426,7 @@ declare module 'fs' {
24222426
recursive?: boolean,
24232427
}>,
24242428
): Promise<Dir>,
2425-
read<T: Buffer | Uint8Array>(
2429+
read<T extends Buffer | Uint8Array>(
24262430
filehandle: FileHandle,
24272431
buffer: T,
24282432
offset: number,
@@ -2503,7 +2507,7 @@ declare module 'fs' {
25032507
overflow?: 'ignore' | 'throw',
25042508
}>,
25052509
): AsyncIterator<{eventType: string, filename: ?string}>,
2506-
write<T: Buffer | Uint8Array>(
2510+
write<T extends Buffer | Uint8Array>(
25072511
filehandle: FileHandle,
25082512
buffer: T,
25092513
offset: number,
@@ -3314,7 +3318,7 @@ declare module 'perf_hooks' {
33143318
now(): number;
33153319
setResourceTimingBufferSize(maxSize: number): void;
33163320
+timeOrigin: number;
3317-
timerify<TArgs: Iterable<unknown>, TReturn>(
3321+
timerify<TArgs extends Iterable<unknown>, TReturn>(
33183322
fn: (...TArgs) => TReturn,
33193323
options?: Readonly<{histogram?: RecordableHistogram}>,
33203324
): (...TArgs) => TReturn;
@@ -3609,7 +3613,7 @@ declare class stream$Readable extends stream$Stream {
36093613
destroy(error?: Error): this;
36103614
isPaused(): boolean;
36113615
pause(): this;
3612-
pipe<T: stream$Writable>(dest: T, options?: {end?: boolean, ...}): T;
3616+
pipe<T extends stream$Writable>(dest: T, options?: {end?: boolean, ...}): T;
36133617
read(size?: number): ?(string | Buffer);
36143618
readable: boolean;
36153619
readableHighWaterMark: number;
@@ -3773,33 +3777,33 @@ declare module 'stream' {
37733777
},
37743778
callback: (error?: Error) => void,
37753779
): () => void;
3776-
declare function pipeline<T: stream$Writable>(
3780+
declare function pipeline<T extends stream$Writable>(
37773781
s1: stream$Readable,
37783782
last: T,
37793783
cb: (error?: Error) => void,
37803784
): T;
3781-
declare function pipeline<T: stream$Writable>(
3785+
declare function pipeline<T extends stream$Writable>(
37823786
s1: stream$Readable,
37833787
s2: stream$Duplex,
37843788
last: T,
37853789
cb: (error?: Error) => void,
37863790
): T;
3787-
declare function pipeline<T: stream$Writable>(
3791+
declare function pipeline<T extends stream$Writable>(
37883792
s1: stream$Readable,
37893793
s2: stream$Duplex,
37903794
s3: stream$Duplex,
37913795
last: T,
37923796
cb: (error?: Error) => void,
37933797
): T;
3794-
declare function pipeline<T: stream$Writable>(
3798+
declare function pipeline<T extends stream$Writable>(
37953799
s1: stream$Readable,
37963800
s2: stream$Duplex,
37973801
s3: stream$Duplex,
37983802
s4: stream$Duplex,
37993803
last: T,
38003804
cb: (error?: Error) => void,
38013805
): T;
3802-
declare function pipeline<T: stream$Writable>(
3806+
declare function pipeline<T extends stream$Writable>(
38033807
s1: stream$Readable,
38043808
s2: stream$Duplex,
38053809
s3: stream$Duplex,
@@ -3808,7 +3812,7 @@ declare module 'stream' {
38083812
last: T,
38093813
cb: (error?: Error) => void,
38103814
): T;
3811-
declare function pipeline<T: stream$Writable>(
3815+
declare function pipeline<T extends stream$Writable>(
38123816
s1: stream$Readable,
38133817
s2: stream$Duplex,
38143818
s3: stream$Duplex,
@@ -4191,19 +4195,19 @@ declare module 'timers' {
41914195
// [key: $SymbolDispose]: () => void;
41924196
}
41934197

4194-
declare export function setTimeout<TArgs: Iterable<unknown>>(
4198+
declare export function setTimeout<TArgs extends Iterable<unknown>>(
41954199
callback: (...args: TArgs) => unknown,
41964200
delay?: number,
41974201
...args: TArgs
41984202
): Timeout;
41994203

4200-
declare export function setInterval<TArgs: Iterable<unknown>>(
4204+
declare export function setInterval<TArgs extends Iterable<unknown>>(
42014205
callback: (...args: TArgs) => unknown,
42024206
delay?: number,
42034207
...args: TArgs
42044208
): Timeout;
42054209

4206-
declare export function setImmediate<TArgs: Iterable<unknown>>(
4210+
declare export function setImmediate<TArgs extends Iterable<unknown>>(
42074211
callback: (...args: TArgs) => unknown,
42084212
...args: TArgs
42094213
): Immediate;
@@ -4500,7 +4504,7 @@ declare module 'util' {
45004504
declare function stripVTControlCharacters(str: string): string;
45014505

45024506
declare function parseArgs<
4503-
TOptions: {+[string]: util$ParseArgsOption} = {},
4507+
TOptions extends {+[string]: util$ParseArgsOption} = {},
45044508
>(config: {
45054509
args?: Array<string>,
45064510
options?: TOptions,
@@ -4514,7 +4518,7 @@ declare module 'util' {
45144518
};
45154519

45164520
declare function parseArgs<
4517-
TOptions: {[string]: util$ParseArgsOption} = {},
4521+
TOptions extends {[string]: util$ParseArgsOption} = {},
45184522
>(config: {
45194523
args?: Array<string>,
45204524
options?: TOptions,
@@ -5658,7 +5662,7 @@ declare class Process extends events$EventEmitter {
56585662
setegid?: (id: number | string) => void;
56595663
seteuid?: (id: number | string) => void;
56605664
setgid?: (id: number | string) => void;
5661-
setgroups?: <Group: string | number>(groups: Array<Group>) => void;
5665+
setgroups?: <Group extends string | number>(groups: Array<Group>) => void;
56625666
setuid?: (id: number | string) => void;
56635667
stderr: stream$Writable | tty$WriteStream;
56645668
stdin: stream$Readable | tty$ReadStream;

flow-typed/npm/@isaacs/ttlcache_1.x.x.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ declare module '@isaacs/ttlcache' {
3131
* as in `cache.set(key, undefined)`. Use `cache.has()` to determine
3232
* whether a key is present in the cache at all.
3333
*/
34-
get<T: V = V>(key: K, options?: TTLCache$GetOptions): T | void;
34+
get<T extends V = V>(key: K, options?: TTLCache$GetOptions): T | void;
3535

3636
/**
3737
* Check if a key is in the cache.

0 commit comments

Comments
 (0)