Skip to content

Commit 48759af

Browse files
SamChou19815facebook-github-bot
authored andcommitted
Name function type params and label dictionary keys in Flow libdefs
Summary: Names the parameters of function types, labels the keys of indexers and drops explicit exact object syntax (`{| |}`) in the Flow library definitions under React Native's `flow-typed/` and `packages/react-native/flow/`, and in Metro's `flow-typed/` (Metro's copies of `environment/node.js` and the `babel`, `babel-types`, `debug` and `yargs` npm libdefs get the same changes as React Native's). They keep type-checking once Flow requires these in library definitions as it already does in other files. Types are unchanged. Changelog: [Internal] Differential Revision: D132693291
1 parent 0c8edf2 commit 48759af

10 files changed

Lines changed: 68 additions & 67 deletions

File tree

‎flow-typed/environment/node.js‎

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,13 +1109,13 @@ declare module 'crypto' {
11091109
salt: string | Buffer,
11101110
keylen: number,
11111111
options:
1112-
| {|N?: number, r?: number, p?: number, maxmem?: number|}
1113-
| {|
1112+
| {N?: number, r?: number, p?: number, maxmem?: number}
1113+
| {
11141114
cost?: number,
11151115
blockSize?: number,
11161116
parallelization?: number,
11171117
maxmem?: number,
1118-
|},
1118+
},
11191119
callback: (err: ?Error, derivedKey: Buffer) => void,
11201120
): void;
11211121
declare function scrypt(
@@ -1129,13 +1129,13 @@ declare module 'crypto' {
11291129
salt: string | Buffer,
11301130
keylen: number,
11311131
options?:
1132-
| {|N?: number, r?: number, p?: number, maxmem?: number|}
1133-
| {|
1132+
| {N?: number, r?: number, p?: number, maxmem?: number}
1133+
| {
11341134
cost?: number,
11351135
blockSize?: number,
11361136
parallelization?: number,
11371137
maxmem?: number,
1138-
|},
1138+
},
11391139
): Buffer;
11401140
declare function privateDecrypt(
11411141
private_key: crypto$key,
@@ -1630,7 +1630,7 @@ declare module 'fs' {
16301630
): void;
16311631
declare function unlinkSync(path: string): void;
16321632

1633-
declare type RmDirOptions = {|
1633+
declare type RmDirOptions = {
16341634
/**
16351635
* If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
16361636
* `EPERM` error is encountered, Node.js will retry the operation with a linear
@@ -1656,7 +1656,7 @@ declare module 'fs' {
16561656
* @default 100
16571657
*/
16581658
retryDelay?: number | void,
1659-
|};
1659+
};
16601660

16611661
declare function rmdir(
16621662
path: PathLike,
@@ -1669,7 +1669,7 @@ declare module 'fs' {
16691669
): void;
16701670
declare function rmdirSync(path: PathLike, options?: RmDirOptions): void;
16711671

1672-
declare type RmOptions = {|
1672+
declare type RmOptions = {
16731673
/**
16741674
* When `true`, exceptions will be ignored if `path` does not exist.
16751675
* @default false
@@ -1696,7 +1696,7 @@ declare module 'fs' {
16961696
* @default 100
16971697
*/
16981698
retryDelay?: number | void,
1699-
|};
1699+
};
17001700

17011701
/**
17021702
* Asynchronously removes files and directories (modeled on the standard POSIX `rm`utility). No arguments other than a possible exception are given to the
@@ -2723,7 +2723,7 @@ declare class https$Server extends tls$Server {
27232723
timeout: number;
27242724
}
27252725

2726-
type requestOptions = {|
2726+
type requestOptions = {
27272727
auth?: string,
27282728
defaultPort?: number,
27292729
family?: number,
@@ -2738,7 +2738,7 @@ type requestOptions = {|
27382738
setHost?: boolean,
27392739
socketPath?: string,
27402740
timeout?: number,
2741-
|};
2741+
};
27422742

27432743
type http$requestOptions = {
27442744
...requestOptions,
@@ -3524,11 +3524,11 @@ declare module 'node:sqlite' {
35243524
): boolean;
35253525
}
35263526

3527-
declare export var constants: {|
3527+
declare export var constants: {
35283528
readonly SQLITE_CHANGESET_OMIT: number,
35293529
readonly SQLITE_CHANGESET_REPLACE: number,
35303530
readonly SQLITE_CHANGESET_ABORT: number,
3531-
|};
3531+
};
35323532
}
35333533

35343534
type readline$InterfaceCompleter = (
@@ -3546,7 +3546,7 @@ declare class readline$Interface extends events$EventEmitter {
35463546
prompt(preserveCursor?: boolean): void;
35473547
question(
35483548
query: string,
3549-
optionsOrCallback: {|signal?: AbortSignal|} | ((answer: string) => void),
3549+
optionsOrCallback: {signal?: AbortSignal} | ((answer: string) => void),
35503550
callback?: (answer: string) => void,
35513551
): void;
35523552
resume(): void;
@@ -4098,7 +4098,7 @@ type tls$Certificate = {
40984098
fingerprint256: string,
40994099
ext_key_usage?: Array<string>,
41004100
subjectaltname?: string,
4101-
infoAccess?: {[string]: Array<string>, ...},
4101+
infoAccess?: {[key: string]: Array<string>, ...},
41024102
issuerCertificate?: tls$Certificate,
41034103
...
41044104
};
@@ -4281,7 +4281,7 @@ declare module 'timers/promises' {
42814281
}
42824282

42834283
declare module 'url' {
4284-
declare type Url = {|
4284+
declare type Url = {
42854285
protocol: string | null,
42864286
slashes: boolean | null,
42874287
auth: string | null,
@@ -4290,21 +4290,21 @@ declare module 'url' {
42904290
hostname: string | null,
42914291
hash: string | null,
42924292
search: string | null,
4293-
query: string | null | {[string]: string, ...},
4293+
query: string | null | {[key: string]: string, ...},
42944294
pathname: string | null,
42954295
path: string | null,
42964296
href: string,
4297-
|};
4297+
};
42984298

4299-
declare type UrlWithStringQuery = {|
4299+
declare type UrlWithStringQuery = {
43004300
...Url,
43014301
query: string | null,
4302-
|};
4302+
};
43034303

4304-
declare type UrlWithParsedQuery = {|
4304+
declare type UrlWithParsedQuery = {
43054305
...Url,
4306-
query: {[string]: string, ...},
4307-
|};
4306+
query: {[key: string]: string, ...},
4307+
};
43084308

43094309
declare function parse(
43104310
urlStr: string,
@@ -4345,7 +4345,7 @@ declare module 'url' {
43454345
| string
43464346
| URLSearchParams
43474347
| Array<[string, string]>
4348-
| {[string]: string, ...},
4348+
| {[key: string]: string, ...},
43494349
): void;
43504350
append(name: string, value: string): void;
43514351
delete(name: string, value?: void): void;
@@ -4494,30 +4494,30 @@ type util$ParseArgsOptionToValue<TOption> = TOption['type'] extends 'boolean'
44944494
: empty;
44954495

44964496
type util$ParseArgsOptionsToValues<TOptions> = {
4497-
[key in keyof TOptions]: util$ParseArgsOptionToValue<{|
4497+
[key in keyof TOptions]: util$ParseArgsOptionToValue<{
44984498
multiple: false,
44994499
...TOptions[key],
4500-
|}>,
4500+
}>,
45014501
};
45024502

45034503
type util$ParseArgsToken =
4504-
| {|
4504+
| {
45054505
kind: 'option',
45064506
index: number,
45074507
name: string,
45084508
rawName: string,
45094509
value?: string,
45104510
inlineValue?: boolean,
4511-
|}
4512-
| {|
4511+
}
4512+
| {
45134513
kind: 'positional',
45144514
index: number,
45154515
value: string,
4516-
|}
4517-
| {|
4516+
}
4517+
| {
45184518
kind: 'option-terminator',
45194519
index: number,
4520-
|};
4520+
};
45214521

45224522
declare module 'util' {
45234523
declare function debuglog(section: string): (data: any, ...args: any) => void;
@@ -4535,7 +4535,7 @@ declare module 'util' {
45354535
declare function stripVTControlCharacters(str: string): string;
45364536

45374537
declare function parseArgs<
4538-
TOptions extends {readonly [string]: util$ParseArgsOption} = {},
4538+
TOptions extends {readonly [key: string]: util$ParseArgsOption} = {},
45394539
>(config: {
45404540
args?: Array<string>,
45414541
options?: TOptions,
@@ -4549,7 +4549,7 @@ declare module 'util' {
45494549
};
45504550

45514551
declare function parseArgs<
4552-
TOptions extends {[string]: util$ParseArgsOption} = {},
4552+
TOptions extends {[key: string]: util$ParseArgsOption} = {},
45534553
>(config: {
45544554
args?: Array<string>,
45554555
options?: TOptions,
@@ -4836,7 +4836,7 @@ type zlib$brotliOptions = {
48364836
finishFlush?: number,
48374837
chunkSize?: number,
48384838
params?: {
4839-
[number]: boolean | number,
4839+
[key: number]: boolean | number,
48404840
...
48414841
},
48424842
maxOutputLength?: number,
@@ -4848,7 +4848,7 @@ type zlib$zstdOptions = {
48484848
finishFlush?: number,
48494849
chunkSize?: number,
48504850
params?: {
4851-
[number]: boolean | number,
4851+
[key: number]: boolean | number,
48524852
...
48534853
},
48544854
maxOutputLength?: number,
@@ -5781,15 +5781,15 @@ declare module 'worker_threads' {
57815781
off(event: string | Symbol, listener: (...args: any[]) => void): this;
57825782
}
57835783

5784-
declare type WorkerOptions = {|
5784+
declare type WorkerOptions = {
57855785
env?: any,
57865786
eval?: boolean,
57875787
workerData?: any,
57885788
stdin?: boolean,
57895789
stdout?: boolean,
57905790
stderr?: boolean,
57915791
execArgv?: string[],
5792-
|};
5792+
};
57935793

57945794
declare class Worker extends events$EventEmitter {
57955795
readonly stdin: stream$Writable | null;

‎flow-typed/npm/babel-types_v7.x.x.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3854,15 +3854,15 @@ declare module "@babel/types" {
38543854
key: string,
38553855
index?: number,
38563856
}>;
3857-
declare export type TraversalHandler<T> = (BabelNode, TraversalAncestors, T) => void;
3857+
declare export type TraversalHandler<T> = (node: BabelNode, parent: TraversalAncestors, state: T) => void;
38583858
declare export type TraversalHandlers<T> = {
38593859
enter?: TraversalHandler<T>,
38603860
exit?: TraversalHandler<T>,
38613861
};
38623862
declare export function traverse<T>(n: BabelNode, handler: TraversalHandler<T> | TraversalHandlers<T>, state?: T): void;
38633863
declare export function traverseFast<T>(n: Node, h: TraversalHandler<T>, state?: T): void;
38643864
declare export function shallowEqual(actual: Object, expected: Object): boolean
3865-
declare export function buildMatchMemberExpression(match: string, allowPartial?: boolean): (?BabelNode) => boolean
3865+
declare export function buildMatchMemberExpression(match: string, allowPartial?: boolean): (member: ?BabelNode) => boolean
38663866
declare export function is(type: string, n: BabelNode, opts: Object): boolean;
38673867
declare export function isBinding(node: BabelNode, parent: BabelNode, grandparent?: BabelNode): boolean
38683868
declare export function isBlockScoped(node: BabelNode): boolean

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ declare module '@babel/core' {
480480
declare export type Presets = Array<PresetEntry>;
481481

482482
// See https://babeljs.io/docs/en/next/options#code-generator-options
483-
declare export type BabelCoreOptions = {|
483+
declare export type BabelCoreOptions = {
484484
// Primary options
485485

486486
/**
@@ -943,16 +943,16 @@ declare module '@babel/core' {
943943
* A root path to include on generated module names.
944944
*/
945945
moduleRoot?: string,
946-
|};
946+
};
947947

948-
declare export type TransformResult<T = BabelFileMetadata> = {|
948+
declare export type TransformResult<T = BabelFileMetadata> = {
949949
metadata: T,
950950
options: BabelCoreOptions,
951951
code: string,
952952
map: _BabelSourceMap | null,
953953
ast: BabelNodeFile | null,
954954
ignored?: boolean,
955-
|};
955+
};
956956

957957
declare type TransformCallback<TMetadata> =
958958
| ((error: Error, result: null) => unknown)
@@ -1252,13 +1252,13 @@ declare module '@babel/generator' {
12521252
declare export default (
12531253
ast: BabelNode,
12541254
options?: Options,
1255-
code?: string | {[string]: string, ...},
1255+
code?: string | {[filename: string]: string, ...},
12561256
) => GeneratorResult;
12571257

12581258
declare export default (
12591259
ast: BabelNode,
12601260
options?: Options,
1261-
code?: string | {|[filename: string]: string|},
1261+
code?: string | {[filename: string]: string},
12621262
) => GeneratorResult;
12631263
}
12641264

@@ -1308,7 +1308,8 @@ declare module '@babel/template' {
13081308
syntacticPlaceholders?: ?boolean,
13091309
};
13101310

1311-
declare export type PublicReplacements = {[string]: ?Node} | Array<?Node>;
1311+
declare export type PublicReplacements =
1312+
{[index: string]: ?Node} | Array<?Node>;
13121313

13131314
declare export type TemplateBuilder<T> = {
13141315
// Build a new builder, merging the given options with the previous ones.

‎flow-typed/npm/debug_v4.4.x.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ declare module 'debug' {
1515
[formatter: string]: (v: unknown) => string;
1616
}
1717

18-
declare type Debugger = {|
18+
declare type Debugger = {
1919
(format: unknown, ...args: Array<unknown>): void,
2020
color: string,
2121
diff: number,
@@ -24,9 +24,9 @@ declare module 'debug' {
2424
namespace: string,
2525
destroy: () => boolean,
2626
extend: (namespace: string, delimiter?: string) => Debugger,
27-
|};
27+
};
2828

29-
declare type Debug = {|
29+
declare type Debug = {
3030
(namespace: string): Debugger,
3131
coerce: (val: unknown) => unknown,
3232
disable: () => string,
@@ -48,7 +48,7 @@ declare module 'debug' {
4848
showHidden?: boolean | number | null,
4949
...
5050
},
51-
|};
51+
};
5252

5353
declare module.exports: Debug;
5454
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ declare module 'execa' {
2121
cwd?: string,
2222
detached?: boolean,
2323
encoding?: string,
24-
env?: {[string]: string | void, ...},
24+
env?: {[key: string]: string | void, ...},
2525
extendEnv?: boolean,
2626
gid?: number,
2727
killSignal?: string | number,

‎flow-typed/npm/node-fetch_v2.x.x.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ declare module 'node-fetch' {
5252

5353
declare type HeaderObject = {[index: string]: string | number, ...};
5454

55-
declare type RequestInit = {|
55+
declare type RequestInit = {
5656
body?: BodyInit,
5757
headers?: HeaderObject | null,
5858
method?: string,
@@ -66,7 +66,7 @@ declare module 'node-fetch' {
6666
follow?: number,
6767
size?: number,
6868
timeout?: number,
69-
|};
69+
};
7070

7171
declare interface FetchError extends Error {
7272
// cannot set name due to incompatible extend error

‎flow-typed/npm/rxjs_v6.x.x.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ declare type rxjs$ObservableInput<T> =
5353
rxjs$SubscribableOrPromise<T> | Array<T> | Iterable<T>;
5454

5555
declare type rxjs$InteropObservable<T> = {
56-
[string | unknown]: () => rxjs$Subscribable<T>,
56+
[key: string | unknown]: () => rxjs$Subscribable<T>,
5757
...
5858
};
5959
/** OBSERVER INTERFACES */

0 commit comments

Comments
 (0)