mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
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
Pull Request resolved: https://github.com/react/react-native/pull/60101
This commit is contained in:
1 parent
0c8edf2aa4
commit
333a401c8c
10 files changed
+68
-67
No files matched your search
Vendored
+39
-39
@@ -1109,13 +1109,13 @@ declare module 'crypto' {
|
||||
salt: string | Buffer,
|
||||
keylen: number,
|
||||
options:
|
||||
| {|N?: number, r?: number, p?: number, maxmem?: number|}
|
||||
| {|
|
||||
| {N?: number, r?: number, p?: number, maxmem?: number}
|
||||
| {
|
||||
cost?: number,
|
||||
blockSize?: number,
|
||||
parallelization?: number,
|
||||
maxmem?: number,
|
||||
|},
|
||||
},
|
||||
callback: (err: ?Error, derivedKey: Buffer) => void,
|
||||
): void;
|
||||
declare function scrypt(
|
||||
@@ -1129,13 +1129,13 @@ declare module 'crypto' {
|
||||
salt: string | Buffer,
|
||||
keylen: number,
|
||||
options?:
|
||||
| {|N?: number, r?: number, p?: number, maxmem?: number|}
|
||||
| {|
|
||||
| {N?: number, r?: number, p?: number, maxmem?: number}
|
||||
| {
|
||||
cost?: number,
|
||||
blockSize?: number,
|
||||
parallelization?: number,
|
||||
maxmem?: number,
|
||||
|},
|
||||
},
|
||||
): Buffer;
|
||||
declare function privateDecrypt(
|
||||
private_key: crypto$key,
|
||||
@@ -1630,7 +1630,7 @@ declare module 'fs' {
|
||||
): void;
|
||||
declare function unlinkSync(path: string): void;
|
||||
|
||||
declare type RmDirOptions = {|
|
||||
declare type RmDirOptions = {
|
||||
/**
|
||||
* If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
|
||||
* `EPERM` error is encountered, Node.js will retry the operation with a linear
|
||||
@@ -1656,7 +1656,7 @@ declare module 'fs' {
|
||||
* @default 100
|
||||
*/
|
||||
retryDelay?: number | void,
|
||||
|};
|
||||
};
|
||||
|
||||
declare function rmdir(
|
||||
path: PathLike,
|
||||
@@ -1669,7 +1669,7 @@ declare module 'fs' {
|
||||
): void;
|
||||
declare function rmdirSync(path: PathLike, options?: RmDirOptions): void;
|
||||
|
||||
declare type RmOptions = {|
|
||||
declare type RmOptions = {
|
||||
/**
|
||||
* When `true`, exceptions will be ignored if `path` does not exist.
|
||||
* @default false
|
||||
@@ -1696,7 +1696,7 @@ declare module 'fs' {
|
||||
* @default 100
|
||||
*/
|
||||
retryDelay?: number | void,
|
||||
|};
|
||||
};
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
timeout: number;
|
||||
}
|
||||
|
||||
type requestOptions = {|
|
||||
type requestOptions = {
|
||||
auth?: string,
|
||||
defaultPort?: number,
|
||||
family?: number,
|
||||
@@ -2738,7 +2738,7 @@ type requestOptions = {|
|
||||
setHost?: boolean,
|
||||
socketPath?: string,
|
||||
timeout?: number,
|
||||
|};
|
||||
};
|
||||
|
||||
type http$requestOptions = {
|
||||
...requestOptions,
|
||||
@@ -3524,11 +3524,11 @@ declare module 'node:sqlite' {
|
||||
): boolean;
|
||||
}
|
||||
|
||||
declare export var constants: {|
|
||||
declare export var constants: {
|
||||
readonly SQLITE_CHANGESET_OMIT: number,
|
||||
readonly SQLITE_CHANGESET_REPLACE: number,
|
||||
readonly SQLITE_CHANGESET_ABORT: number,
|
||||
|};
|
||||
};
|
||||
}
|
||||
|
||||
type readline$InterfaceCompleter = (
|
||||
@@ -3546,7 +3546,7 @@ declare class readline$Interface extends events$EventEmitter {
|
||||
prompt(preserveCursor?: boolean): void;
|
||||
question(
|
||||
query: string,
|
||||
optionsOrCallback: {|signal?: AbortSignal|} | ((answer: string) => void),
|
||||
optionsOrCallback: {signal?: AbortSignal} | ((answer: string) => void),
|
||||
callback?: (answer: string) => void,
|
||||
): void;
|
||||
resume(): void;
|
||||
@@ -4098,7 +4098,7 @@ type tls$Certificate = {
|
||||
fingerprint256: string,
|
||||
ext_key_usage?: Array<string>,
|
||||
subjectaltname?: string,
|
||||
infoAccess?: {[string]: Array<string>, ...},
|
||||
infoAccess?: {[key: string]: Array<string>, ...},
|
||||
issuerCertificate?: tls$Certificate,
|
||||
...
|
||||
};
|
||||
@@ -4281,7 +4281,7 @@ declare module 'timers/promises' {
|
||||
}
|
||||
|
||||
declare module 'url' {
|
||||
declare type Url = {|
|
||||
declare type Url = {
|
||||
protocol: string | null,
|
||||
slashes: boolean | null,
|
||||
auth: string | null,
|
||||
@@ -4290,21 +4290,21 @@ declare module 'url' {
|
||||
hostname: string | null,
|
||||
hash: string | null,
|
||||
search: string | null,
|
||||
query: string | null | {[string]: string, ...},
|
||||
query: string | null | {[key: string]: string, ...},
|
||||
pathname: string | null,
|
||||
path: string | null,
|
||||
href: string,
|
||||
|};
|
||||
};
|
||||
|
||||
declare type UrlWithStringQuery = {|
|
||||
declare type UrlWithStringQuery = {
|
||||
...Url,
|
||||
query: string | null,
|
||||
|};
|
||||
};
|
||||
|
||||
declare type UrlWithParsedQuery = {|
|
||||
declare type UrlWithParsedQuery = {
|
||||
...Url,
|
||||
query: {[string]: string, ...},
|
||||
|};
|
||||
query: {[key: string]: string, ...},
|
||||
};
|
||||
|
||||
declare function parse(
|
||||
urlStr: string,
|
||||
@@ -4345,7 +4345,7 @@ declare module 'url' {
|
||||
| string
|
||||
| URLSearchParams
|
||||
| Array<[string, string]>
|
||||
| {[string]: string, ...},
|
||||
| {[key: string]: string, ...},
|
||||
): void;
|
||||
append(name: string, value: string): void;
|
||||
delete(name: string, value?: void): void;
|
||||
@@ -4494,30 +4494,30 @@ type util$ParseArgsOptionToValue<TOption> = TOption['type'] extends 'boolean'
|
||||
: empty;
|
||||
|
||||
type util$ParseArgsOptionsToValues<TOptions> = {
|
||||
[key in keyof TOptions]: util$ParseArgsOptionToValue<{|
|
||||
[key in keyof TOptions]: util$ParseArgsOptionToValue<{
|
||||
multiple: false,
|
||||
...TOptions[key],
|
||||
|}>,
|
||||
}>,
|
||||
};
|
||||
|
||||
type util$ParseArgsToken =
|
||||
| {|
|
||||
| {
|
||||
kind: 'option',
|
||||
index: number,
|
||||
name: string,
|
||||
rawName: string,
|
||||
value?: string,
|
||||
inlineValue?: boolean,
|
||||
|}
|
||||
| {|
|
||||
}
|
||||
| {
|
||||
kind: 'positional',
|
||||
index: number,
|
||||
value: string,
|
||||
|}
|
||||
| {|
|
||||
}
|
||||
| {
|
||||
kind: 'option-terminator',
|
||||
index: number,
|
||||
|};
|
||||
};
|
||||
|
||||
declare module 'util' {
|
||||
declare function debuglog(section: string): (data: any, ...args: any) => void;
|
||||
@@ -4535,7 +4535,7 @@ declare module 'util' {
|
||||
declare function stripVTControlCharacters(str: string): string;
|
||||
|
||||
declare function parseArgs<
|
||||
TOptions extends {readonly [string]: util$ParseArgsOption} = {},
|
||||
TOptions extends {readonly [key: string]: util$ParseArgsOption} = {},
|
||||
>(config: {
|
||||
args?: Array<string>,
|
||||
options?: TOptions,
|
||||
@@ -4549,7 +4549,7 @@ declare module 'util' {
|
||||
};
|
||||
|
||||
declare function parseArgs<
|
||||
TOptions extends {[string]: util$ParseArgsOption} = {},
|
||||
TOptions extends {[key: string]: util$ParseArgsOption} = {},
|
||||
>(config: {
|
||||
args?: Array<string>,
|
||||
options?: TOptions,
|
||||
@@ -4836,7 +4836,7 @@ type zlib$brotliOptions = {
|
||||
finishFlush?: number,
|
||||
chunkSize?: number,
|
||||
params?: {
|
||||
[number]: boolean | number,
|
||||
[key: number]: boolean | number,
|
||||
...
|
||||
},
|
||||
maxOutputLength?: number,
|
||||
@@ -4848,7 +4848,7 @@ type zlib$zstdOptions = {
|
||||
finishFlush?: number,
|
||||
chunkSize?: number,
|
||||
params?: {
|
||||
[number]: boolean | number,
|
||||
[key: number]: boolean | number,
|
||||
...
|
||||
},
|
||||
maxOutputLength?: number,
|
||||
@@ -5781,7 +5781,7 @@ declare module 'worker_threads' {
|
||||
off(event: string | Symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
|
||||
declare type WorkerOptions = {|
|
||||
declare type WorkerOptions = {
|
||||
env?: any,
|
||||
eval?: boolean,
|
||||
workerData?: any,
|
||||
@@ -5789,7 +5789,7 @@ declare module 'worker_threads' {
|
||||
stdout?: boolean,
|
||||
stderr?: boolean,
|
||||
execArgv?: string[],
|
||||
|};
|
||||
};
|
||||
|
||||
declare class Worker extends events$EventEmitter {
|
||||
readonly stdin: stream$Writable | null;
|
||||
|
||||
Vendored
+2
-2
@@ -3854,7 +3854,7 @@ declare module "@babel/types" {
|
||||
key: string,
|
||||
index?: number,
|
||||
}>;
|
||||
declare export type TraversalHandler<T> = (BabelNode, TraversalAncestors, T) => void;
|
||||
declare export type TraversalHandler<T> = (node: BabelNode, parent: TraversalAncestors, state: T) => void;
|
||||
declare export type TraversalHandlers<T> = {
|
||||
enter?: TraversalHandler<T>,
|
||||
exit?: TraversalHandler<T>,
|
||||
@@ -3862,7 +3862,7 @@ declare module "@babel/types" {
|
||||
declare export function traverse<T>(n: BabelNode, handler: TraversalHandler<T> | TraversalHandlers<T>, state?: T): void;
|
||||
declare export function traverseFast<T>(n: Node, h: TraversalHandler<T>, state?: T): void;
|
||||
declare export function shallowEqual(actual: Object, expected: Object): boolean
|
||||
declare export function buildMatchMemberExpression(match: string, allowPartial?: boolean): (?BabelNode) => boolean
|
||||
declare export function buildMatchMemberExpression(match: string, allowPartial?: boolean): (member: ?BabelNode) => boolean
|
||||
declare export function is(type: string, n: BabelNode, opts: Object): boolean;
|
||||
declare export function isBinding(node: BabelNode, parent: BabelNode, grandparent?: BabelNode): boolean
|
||||
declare export function isBlockScoped(node: BabelNode): boolean
|
||||
|
||||
Vendored
+8
-7
@@ -480,7 +480,7 @@ declare module '@babel/core' {
|
||||
declare export type Presets = Array<PresetEntry>;
|
||||
|
||||
// See https://babeljs.io/docs/en/next/options#code-generator-options
|
||||
declare export type BabelCoreOptions = {|
|
||||
declare export type BabelCoreOptions = {
|
||||
// Primary options
|
||||
|
||||
/**
|
||||
@@ -943,16 +943,16 @@ declare module '@babel/core' {
|
||||
* A root path to include on generated module names.
|
||||
*/
|
||||
moduleRoot?: string,
|
||||
|};
|
||||
};
|
||||
|
||||
declare export type TransformResult<T = BabelFileMetadata> = {|
|
||||
declare export type TransformResult<T = BabelFileMetadata> = {
|
||||
metadata: T,
|
||||
options: BabelCoreOptions,
|
||||
code: string,
|
||||
map: _BabelSourceMap | null,
|
||||
ast: BabelNodeFile | null,
|
||||
ignored?: boolean,
|
||||
|};
|
||||
};
|
||||
|
||||
declare type TransformCallback<TMetadata> =
|
||||
| ((error: Error, result: null) => unknown)
|
||||
@@ -1252,13 +1252,13 @@ declare module '@babel/generator' {
|
||||
declare export default (
|
||||
ast: BabelNode,
|
||||
options?: Options,
|
||||
code?: string | {[string]: string, ...},
|
||||
code?: string | {[filename: string]: string, ...},
|
||||
) => GeneratorResult;
|
||||
|
||||
declare export default (
|
||||
ast: BabelNode,
|
||||
options?: Options,
|
||||
code?: string | {|[filename: string]: string|},
|
||||
code?: string | {[filename: string]: string},
|
||||
) => GeneratorResult;
|
||||
}
|
||||
|
||||
@@ -1308,7 +1308,8 @@ declare module '@babel/template' {
|
||||
syntacticPlaceholders?: ?boolean,
|
||||
};
|
||||
|
||||
declare export type PublicReplacements = {[string]: ?Node} | Array<?Node>;
|
||||
declare export type PublicReplacements =
|
||||
{[index: string]: ?Node} | Array<?Node>;
|
||||
|
||||
declare export type TemplateBuilder<T> = {
|
||||
// Build a new builder, merging the given options with the previous ones.
|
||||
|
||||
Vendored
+4
-4
@@ -15,7 +15,7 @@ declare module 'debug' {
|
||||
[formatter: string]: (v: unknown) => string;
|
||||
}
|
||||
|
||||
declare type Debugger = {|
|
||||
declare type Debugger = {
|
||||
(format: unknown, ...args: Array<unknown>): void,
|
||||
color: string,
|
||||
diff: number,
|
||||
@@ -24,9 +24,9 @@ declare module 'debug' {
|
||||
namespace: string,
|
||||
destroy: () => boolean,
|
||||
extend: (namespace: string, delimiter?: string) => Debugger,
|
||||
|};
|
||||
};
|
||||
|
||||
declare type Debug = {|
|
||||
declare type Debug = {
|
||||
(namespace: string): Debugger,
|
||||
coerce: (val: unknown) => unknown,
|
||||
disable: () => string,
|
||||
@@ -48,7 +48,7 @@ declare module 'debug' {
|
||||
showHidden?: boolean | number | null,
|
||||
...
|
||||
},
|
||||
|};
|
||||
};
|
||||
|
||||
declare module.exports: Debug;
|
||||
}
|
||||
Vendored
+1
-1
@@ -21,7 +21,7 @@ declare module 'execa' {
|
||||
cwd?: string,
|
||||
detached?: boolean,
|
||||
encoding?: string,
|
||||
env?: {[string]: string | void, ...},
|
||||
env?: {[key: string]: string | void, ...},
|
||||
extendEnv?: boolean,
|
||||
gid?: number,
|
||||
killSignal?: string | number,
|
||||
|
||||
Vendored
+2
-2
@@ -52,7 +52,7 @@ declare module 'node-fetch' {
|
||||
|
||||
declare type HeaderObject = {[index: string]: string | number, ...};
|
||||
|
||||
declare type RequestInit = {|
|
||||
declare type RequestInit = {
|
||||
body?: BodyInit,
|
||||
headers?: HeaderObject | null,
|
||||
method?: string,
|
||||
@@ -66,7 +66,7 @@ declare module 'node-fetch' {
|
||||
follow?: number,
|
||||
size?: number,
|
||||
timeout?: number,
|
||||
|};
|
||||
};
|
||||
|
||||
declare interface FetchError extends Error {
|
||||
// cannot set name due to incompatible extend error
|
||||
|
||||
Vendored
+1
-1
@@ -53,7 +53,7 @@ declare type rxjs$ObservableInput<T> =
|
||||
rxjs$SubscribableOrPromise<T> | Array<T> | Iterable<T>;
|
||||
|
||||
declare type rxjs$InteropObservable<T> = {
|
||||
[string | unknown]: () => rxjs$Subscribable<T>,
|
||||
[key: string | unknown]: () => rxjs$Subscribable<T>,
|
||||
...
|
||||
};
|
||||
/** OBSERVER INTERFACES */
|
||||
|
||||
Vendored
+8
-8
@@ -46,29 +46,29 @@ declare module 'yargs' {
|
||||
...
|
||||
}>;
|
||||
|
||||
declare type CommonCommandModule = {|
|
||||
declare type CommonCommandModule = {
|
||||
command?: string | Array<string>,
|
||||
aliases?: Array<string> | string,
|
||||
builder?:
|
||||
| {[key: string]: Options, ...}
|
||||
| ((yargsInstance: Yargs) => unknown),
|
||||
handler?: ((argv: Argv) => void) | ((argv: Argv) => Promise<void>),
|
||||
|};
|
||||
};
|
||||
|
||||
declare type CommandModuleDesc = {|
|
||||
declare type CommandModuleDesc = {
|
||||
...CommonCommandModule,
|
||||
desc?: string | false,
|
||||
|};
|
||||
};
|
||||
|
||||
declare type CommandModuleDescribe = {|
|
||||
declare type CommandModuleDescribe = {
|
||||
...CommonCommandModule,
|
||||
describe?: string | false,
|
||||
|};
|
||||
};
|
||||
|
||||
declare type CommandModuleDescription = {|
|
||||
declare type CommandModuleDescription = {
|
||||
...CommonCommandModule,
|
||||
description?: string | false,
|
||||
|};
|
||||
};
|
||||
|
||||
declare type CommandModule =
|
||||
| CommandModuleDesc
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ declare type $HermesInternalType = {
|
||||
* @return An object that maps strings to various types of performance
|
||||
* statistics.
|
||||
*/
|
||||
readonly getInstrumentedStats?: () => {[string]: number | string, ...},
|
||||
readonly getInstrumentedStats?: () => {[key: string]: number | string, ...},
|
||||
|
||||
/**
|
||||
* Query the VM for any sort of runtime properties that it wants to report.
|
||||
@@ -59,7 +59,7 @@ declare type $HermesInternalType = {
|
||||
readonly getRuntimeProperties?: () => {
|
||||
'OSS Release Version': string,
|
||||
Build: string,
|
||||
[string]: unknown,
|
||||
[key: string]: unknown,
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+1
-1
@@ -86,7 +86,7 @@ declare var global: {
|
||||
readonly structuredClone: typeof structuredClone,
|
||||
|
||||
// Undeclared properties are implicitly `any`.
|
||||
[string | symbol]: any,
|
||||
[key: string | symbol]: any,
|
||||
};
|
||||
|
||||
// Declared as a bare global so unqualified `__DEV__` references type-check as
|
||||
|
||||
Reference in new issue
Block a user