mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Transform another round of xplat (#55217)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55217 tsia Changelog: [internal] Reviewed By: SamChou19815 Differential Revision: D90914123 fbshipit-source-id: dc28b22524d3c6e6487d28cad30cc53a92ea8b83
This commit is contained in:
1 parent
d9ee4bb0aa
commit
23aa4ddbac
5 files changed
+169
-142
No files matched your search
Vendored
+24
-26
@@ -4,44 +4,44 @@ declare module 'react-dom' {
|
||||
declare var version: string;
|
||||
|
||||
declare function findDOMNode(
|
||||
componentOrElement: Element | ?Component<any, any>
|
||||
componentOrElement: Element | ?Component<any, any>,
|
||||
): null | Element | Text;
|
||||
|
||||
declare function render<ElementType: React.ElementType>(
|
||||
element: ExactReactElement_DEPRECATED<ElementType>,
|
||||
container: Element,
|
||||
callback?: () => void
|
||||
callback?: () => void,
|
||||
): React.ElementRef<ElementType>;
|
||||
|
||||
declare function hydrate<ElementType: React.ElementType>(
|
||||
element: ExactReactElement_DEPRECATED<ElementType>,
|
||||
container: Element,
|
||||
callback?: () => void
|
||||
callback?: () => void,
|
||||
): React.ElementRef<ElementType>;
|
||||
|
||||
declare function createPortal(
|
||||
node: React.Node,
|
||||
container: Element
|
||||
container: Element,
|
||||
): React.Portal;
|
||||
|
||||
declare function unmountComponentAtNode(container: any): boolean;
|
||||
|
||||
declare function unstable_batchedUpdates<A, B, C, D, E>(
|
||||
callback: (a: A, b: B, c: C, d: D, e: E) => mixed,
|
||||
callback: (a: A, b: B, c: C, d: D, e: E) => unknown,
|
||||
a: A,
|
||||
b: B,
|
||||
c: C,
|
||||
d: D,
|
||||
e: E
|
||||
e: E,
|
||||
): void;
|
||||
|
||||
declare function unstable_renderSubtreeIntoContainer<
|
||||
ElementType: React.ElementType
|
||||
ElementType: React.ElementType,
|
||||
>(
|
||||
parentComponent: Component<any, any>,
|
||||
nextElement: ExactReactElement_DEPRECATED<ElementType>,
|
||||
container: any,
|
||||
callback?: () => void
|
||||
callback?: () => void,
|
||||
): React.ElementRef<ElementType>;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ declare module 'react-dom/server' {
|
||||
declare function renderToNodeStream(element: React.Node): stream$Readable;
|
||||
|
||||
declare function renderToStaticNodeStream(
|
||||
element: React.Node
|
||||
element: React.Node,
|
||||
): stream$Readable;
|
||||
}
|
||||
|
||||
@@ -63,77 +63,75 @@ declare module 'react-dom/test-utils' {
|
||||
import type {Component} from 'react';
|
||||
|
||||
declare interface Thenable {
|
||||
then(resolve: () => mixed, reject?: () => mixed): mixed,
|
||||
then(resolve: () => unknown, reject?: () => unknown): unknown;
|
||||
}
|
||||
|
||||
declare var Simulate: {
|
||||
[eventName: string]: (
|
||||
element: Element,
|
||||
eventData?: { [key: string]: mixed, ... }
|
||||
eventData?: {[key: string]: unknown, ...},
|
||||
) => void,
|
||||
...
|
||||
};
|
||||
|
||||
declare function renderIntoDocument(
|
||||
instance: React.MixedElement
|
||||
instance: React.MixedElement,
|
||||
): Component<any, any>;
|
||||
|
||||
declare function mockComponent(
|
||||
componentClass: React.ElementType,
|
||||
mockTagName?: string
|
||||
): { [key: string]: mixed, ... };
|
||||
mockTagName?: string,
|
||||
): {[key: string]: unknown, ...};
|
||||
|
||||
declare function isElement(element: React.MixedElement): boolean;
|
||||
|
||||
declare function isElementOfType(
|
||||
element: React.MixedElement,
|
||||
componentClass: React.ElementType
|
||||
componentClass: React.ElementType,
|
||||
): boolean;
|
||||
|
||||
declare function isDOMComponent(instance: any): boolean;
|
||||
|
||||
declare function isCompositeComponent(
|
||||
instance: Component<any, any>
|
||||
): boolean;
|
||||
declare function isCompositeComponent(instance: Component<any, any>): boolean;
|
||||
|
||||
declare function isCompositeComponentWithType(
|
||||
instance: Component<any, any>,
|
||||
componentClass: React.ElementType
|
||||
componentClass: React.ElementType,
|
||||
): boolean;
|
||||
|
||||
declare function findAllInRenderedTree(
|
||||
tree: Component<any, any>,
|
||||
test: (child: Component<any, any>) => boolean
|
||||
test: (child: Component<any, any>) => boolean,
|
||||
): Array<Component<any, any>>;
|
||||
|
||||
declare function scryRenderedDOMComponentsWithClass(
|
||||
tree: Component<any, any>,
|
||||
className: string
|
||||
className: string,
|
||||
): Array<Element>;
|
||||
|
||||
declare function findRenderedDOMComponentWithClass(
|
||||
tree: Component<any, any>,
|
||||
className: string
|
||||
className: string,
|
||||
): ?Element;
|
||||
|
||||
declare function scryRenderedDOMComponentsWithTag(
|
||||
tree: Component<any, any>,
|
||||
tagName: string
|
||||
tagName: string,
|
||||
): Array<Element>;
|
||||
|
||||
declare function findRenderedDOMComponentWithTag(
|
||||
tree: Component<any, any>,
|
||||
tagName: string
|
||||
tagName: string,
|
||||
): ?Element;
|
||||
|
||||
declare function scryRenderedComponentsWithType(
|
||||
tree: Component<any, any>,
|
||||
componentClass: React.ElementType
|
||||
componentClass: React.ElementType,
|
||||
): Array<Component<any, any>>;
|
||||
|
||||
declare function findRenderedComponentWithType(
|
||||
tree: Component<any, any>,
|
||||
componentClass: React.ElementType
|
||||
componentClass: React.ElementType,
|
||||
): ?Component<any, any>;
|
||||
|
||||
declare function act(callback: () => void | Thenable): Thenable;
|
||||
|
||||
+19
-13
@@ -1,22 +1,25 @@
|
||||
// Type definitions for react-test-renderer 16.x.x
|
||||
// Ported from: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-test-renderer
|
||||
|
||||
type TestRendererOptions = { createNodeMock(element: React.MixedElement): any, ... };
|
||||
type TestRendererOptions = {
|
||||
createNodeMock(element: React.MixedElement): any,
|
||||
...
|
||||
};
|
||||
|
||||
declare module "react-test-renderer" {
|
||||
declare module 'react-test-renderer' {
|
||||
import type {Component as ReactComponent} from 'react';
|
||||
|
||||
type ReactComponentInstance = ReactComponent<any>;
|
||||
|
||||
export type ReactTestRendererJSON = {
|
||||
type: string,
|
||||
props: { [propName: string]: any, ... },
|
||||
props: {[propName: string]: any, ...},
|
||||
children: null | ReactTestRendererJSON[],
|
||||
...
|
||||
};
|
||||
|
||||
export type ReactTestRendererTree = ReactTestRendererJSON & {
|
||||
nodeType: "component" | "host",
|
||||
nodeType: 'component' | 'host',
|
||||
instance: ?ReactComponentInstance,
|
||||
rendered: null | ReactTestRendererTree,
|
||||
...
|
||||
@@ -25,23 +28,23 @@ declare module "react-test-renderer" {
|
||||
export type ReactTestInstance = {
|
||||
instance: ?ReactComponentInstance,
|
||||
type: string,
|
||||
props: { [propName: string]: any, ... },
|
||||
props: {[propName: string]: any, ...},
|
||||
parent: null | ReactTestInstance,
|
||||
children: Array<ReactTestInstance | string>,
|
||||
find(predicate: (node: ReactTestInstance) => boolean): ReactTestInstance,
|
||||
findByType(type: React.ElementType): ReactTestInstance,
|
||||
findByProps(props: { [propName: string]: any, ... }): ReactTestInstance,
|
||||
findByProps(props: {[propName: string]: any, ...}): ReactTestInstance,
|
||||
findAll(
|
||||
predicate: (node: ReactTestInstance) => boolean,
|
||||
options?: { deep: boolean, ... }
|
||||
options?: {deep: boolean, ...},
|
||||
): ReactTestInstance[],
|
||||
findAllByType(
|
||||
type: React.ElementType,
|
||||
options?: { deep: boolean, ... }
|
||||
options?: {deep: boolean, ...},
|
||||
): ReactTestInstance[],
|
||||
findAllByProps(
|
||||
props: { [propName: string]: any, ... },
|
||||
options?: { deep: boolean, ... }
|
||||
props: {[propName: string]: any, ...},
|
||||
options?: {deep: boolean, ...},
|
||||
): ReactTestInstance[],
|
||||
...
|
||||
};
|
||||
@@ -56,17 +59,20 @@ declare module "react-test-renderer" {
|
||||
...
|
||||
};
|
||||
|
||||
declare type Thenable = { then(resolve: () => mixed, reject?: () => mixed): mixed, ... };
|
||||
declare type Thenable = {
|
||||
then(resolve: () => unknown, reject?: () => unknown): unknown,
|
||||
...
|
||||
};
|
||||
|
||||
declare function create(
|
||||
nextElement: React.MixedElement,
|
||||
options?: TestRendererOptions
|
||||
options?: TestRendererOptions,
|
||||
): ReactTestRenderer;
|
||||
|
||||
declare function act(callback: () => void | Promise<void>): Thenable;
|
||||
}
|
||||
|
||||
declare module "react-test-renderer/shallow" {
|
||||
declare module 'react-test-renderer/shallow' {
|
||||
import type {ReactTestInstance} from 'react-test-renderer';
|
||||
|
||||
declare export default class ShallowRenderer {
|
||||
|
||||
Vendored
+15
-6
@@ -16,18 +16,27 @@ declare module 'tinyglobby' {
|
||||
followSymbolicLinks?: boolean,
|
||||
fs?: FileSystemAdapter,
|
||||
globstar?: boolean,
|
||||
ignore?: string | $ReadOnlyArray<string>,
|
||||
ignore?: string | ReadonlyArray<string>,
|
||||
onlyDirectories?: boolean,
|
||||
onlyFiles?: boolean,
|
||||
signal?: AbortSignal,
|
||||
};
|
||||
|
||||
declare type GlobModule = {
|
||||
convertPathToPattern(path: string): string;
|
||||
escapePath(path: string): string;
|
||||
isDynamicPattern(pattern: string, options?: { caseSensitiveMatch: boolean }): boolean;
|
||||
glob(patterns: string | $ReadOnlyArray<string>, options?: GlobOptions): Promise<string[]>;
|
||||
globSync(patterns: string | $ReadOnlyArray<string>, options?: GlobOptions): string[];
|
||||
convertPathToPattern(path: string): string,
|
||||
escapePath(path: string): string,
|
||||
isDynamicPattern(
|
||||
pattern: string,
|
||||
options?: {caseSensitiveMatch: boolean},
|
||||
): boolean,
|
||||
glob(
|
||||
patterns: string | ReadonlyArray<string>,
|
||||
options?: GlobOptions,
|
||||
): Promise<string[]>,
|
||||
globSync(
|
||||
patterns: string | ReadonlyArray<string>,
|
||||
options?: GlobOptions,
|
||||
): string[],
|
||||
};
|
||||
|
||||
declare module.exports: GlobModule;
|
||||
|
||||
Vendored
+101
-85
@@ -1,6 +1,6 @@
|
||||
// flow-typed version: f7c859e705/yargs_v17.x.x/flow_>=v0.104.x
|
||||
|
||||
declare module "yargs" {
|
||||
declare module 'yargs' {
|
||||
declare type Argv = {
|
||||
[key: string]: any,
|
||||
_: Array<string>,
|
||||
@@ -12,13 +12,13 @@ declare module "yargs" {
|
||||
alias: string | Array<string>,
|
||||
array: boolean,
|
||||
boolean: boolean,
|
||||
choices: Array<mixed>,
|
||||
coerce: (arg: {[key: string]: any, ...} | any) => mixed,
|
||||
choices: Array<unknown>,
|
||||
coerce: (arg: {[key: string]: any, ...} | any) => unknown,
|
||||
config: boolean,
|
||||
configParser: (configPath: string) => { [key: string]: mixed, ... },
|
||||
conflicts: string | Array<string> | { [key: string]: string, ... },
|
||||
configParser: (configPath: string) => {[key: string]: unknown, ...},
|
||||
conflicts: string | Array<string> | {[key: string]: string, ...},
|
||||
count: boolean,
|
||||
default: mixed,
|
||||
default: unknown,
|
||||
defaultDescription: string,
|
||||
demandOption: boolean | string,
|
||||
desc: string,
|
||||
@@ -27,7 +27,7 @@ declare module "yargs" {
|
||||
global: boolean,
|
||||
group: string,
|
||||
hidden: boolean,
|
||||
implies: string | { [key: string]: string, ... },
|
||||
implies: string | {[key: string]: string, ...},
|
||||
nargs: number,
|
||||
normalize: boolean,
|
||||
number: boolean,
|
||||
@@ -35,30 +35,32 @@ declare module "yargs" {
|
||||
requiresArg: boolean,
|
||||
skipValidation: boolean,
|
||||
string: boolean,
|
||||
type: "array" | "boolean" | "count" | "number" | "string",
|
||||
type: 'array' | 'boolean' | 'count' | 'number' | 'string',
|
||||
...
|
||||
}>;
|
||||
|
||||
declare type CommonModuleObject = {|
|
||||
command?: string | Array<string>,
|
||||
aliases?: Array<string> | string,
|
||||
builder?: { [key: string]: Options, ... } | ((yargsInstance: Yargs) => mixed),
|
||||
handler?: ((argv: Argv) => void) | ((argv: Argv) => Promise<void>)
|
||||
builder?:
|
||||
| {[key: string]: Options, ...}
|
||||
| ((yargsInstance: Yargs) => unknown),
|
||||
handler?: ((argv: Argv) => void) | ((argv: Argv) => Promise<void>),
|
||||
|};
|
||||
|
||||
declare type ModuleObjectDesc = {|
|
||||
...CommonModuleObject,
|
||||
desc?: string | false
|
||||
desc?: string | false,
|
||||
|};
|
||||
|
||||
declare type ModuleObjectDescribe = {|
|
||||
...CommonModuleObject,
|
||||
describe?: string | false
|
||||
describe?: string | false,
|
||||
|};
|
||||
|
||||
declare type ModuleObjectDescription = {|
|
||||
...CommonModuleObject,
|
||||
description?: string | false
|
||||
description?: string | false,
|
||||
|};
|
||||
|
||||
declare type ModuleObject =
|
||||
@@ -66,9 +68,10 @@ declare module "yargs" {
|
||||
| ModuleObjectDescribe
|
||||
| ModuleObjectDescription;
|
||||
|
||||
declare type MiddleWareCallback =
|
||||
| (argv: Argv, yargsInstance?: Yargs) => void
|
||||
| (argv: Argv, yargsInstance?: Yargs) => Promise<void>;
|
||||
declare type MiddleWareCallback = (
|
||||
argv: Argv,
|
||||
yargsInstance?: Yargs,
|
||||
) => void | ((argv: Argv, yargsInstance?: Yargs) => Promise<void>);
|
||||
|
||||
declare type Middleware = MiddleWareCallback | Array<MiddleWareCallback>;
|
||||
|
||||
@@ -76,29 +79,29 @@ declare module "yargs" {
|
||||
(args: Array<string>): Yargs;
|
||||
|
||||
alias(key: string, alias: string): this;
|
||||
alias(alias: { [key: string]: string | Array<string>, ... }): this;
|
||||
alias(alias: {[key: string]: string | Array<string>, ...}): this;
|
||||
argv: Argv | Promise<Argv>;
|
||||
array(key: string | Array<string>): this;
|
||||
boolean(parameter: string | Array<string>): this;
|
||||
check(fn: (argv: Argv, options: Array<string>) => mixed): this;
|
||||
check(fn: (argv: Argv, options: Array<string>) => unknown): this;
|
||||
choices(key: string, allowed: Array<string>): this;
|
||||
choices(allowed: { [key: string]: Array<string>, ... }): this;
|
||||
coerce(key: string, fn: (value: any) => mixed): this;
|
||||
coerce(object: { [key: string]: (value: any) => mixed, ... }): this;
|
||||
coerce(keys: Array<string>, fn: (value: any) => mixed): this;
|
||||
choices(allowed: {[key: string]: Array<string>, ...}): this;
|
||||
coerce(key: string, fn: (value: any) => unknown): this;
|
||||
coerce(object: {[key: string]: (value: any) => unknown, ...}): this;
|
||||
coerce(keys: Array<string>, fn: (value: any) => unknown): this;
|
||||
|
||||
command(
|
||||
cmd: string | Array<string>,
|
||||
desc: string | false,
|
||||
builder?:
|
||||
| { [key: string]: Options, ... }
|
||||
| ((yargsInstance: Yargs) => mixed),
|
||||
handler?: Function
|
||||
| {[key: string]: Options, ...}
|
||||
| ((yargsInstance: Yargs) => unknown),
|
||||
handler?: Function,
|
||||
): this;
|
||||
command(
|
||||
cmd: string | Array<string>,
|
||||
desc: string | false,
|
||||
module: ModuleObject
|
||||
module: ModuleObject,
|
||||
): this;
|
||||
command(module: ModuleObject): this;
|
||||
|
||||
@@ -106,14 +109,14 @@ declare module "yargs" {
|
||||
cmd: string | Array<string>,
|
||||
desc: string | false,
|
||||
builder?:
|
||||
| { [key: string]: Options, ... }
|
||||
| ((yargsInstance: Yargs) => mixed),
|
||||
handler?: Function
|
||||
| {[key: string]: Options, ...}
|
||||
| ((yargsInstance: Yargs) => unknown),
|
||||
handler?: Function,
|
||||
): this;
|
||||
commands(
|
||||
cmd: string | Array<string>,
|
||||
desc: string | false,
|
||||
module: ModuleObject
|
||||
module: ModuleObject,
|
||||
): this;
|
||||
commands(module: ModuleObject): this;
|
||||
|
||||
@@ -131,36 +134,39 @@ declare module "yargs" {
|
||||
|
||||
completion(
|
||||
cmd?: string,
|
||||
description?: string | false | (
|
||||
current: string,
|
||||
argv: Argv,
|
||||
done: (compeltion: Array<string>) => void
|
||||
) => ?(Array<string> | Promise<Array<string>>),
|
||||
description?:
|
||||
| string
|
||||
| false
|
||||
| ((
|
||||
current: string,
|
||||
argv: Argv,
|
||||
done: (compeltion: Array<string>) => void,
|
||||
) => ?(Array<string> | Promise<Array<string>>)),
|
||||
fn?: (
|
||||
current: string,
|
||||
argv: Argv,
|
||||
done: (completion: Array<string>) => void
|
||||
) => ?(Array<string> | Promise<Array<string>>)
|
||||
done: (completion: Array<string>) => void,
|
||||
) => ?(Array<string> | Promise<Array<string>>),
|
||||
): this;
|
||||
|
||||
config(
|
||||
key?: string,
|
||||
description?: string,
|
||||
parseFn?: (configPath: string) => { [key: string]: mixed, ... }
|
||||
parseFn?: (configPath: string) => {[key: string]: unknown, ...},
|
||||
): this;
|
||||
config(
|
||||
key: string,
|
||||
parseFn?: (configPath: string) => { [key: string]: mixed, ... }
|
||||
parseFn?: (configPath: string) => {[key: string]: unknown, ...},
|
||||
): this;
|
||||
config(config: { [key: string]: mixed, ... }): this;
|
||||
config(config: {[key: string]: unknown, ...}): this;
|
||||
|
||||
conflicts(key: string, value: string | Array<string>): this;
|
||||
conflicts(keys: { [key: string]: string | Array<string>, ... }): this;
|
||||
conflicts(keys: {[key: string]: string | Array<string>, ...}): this;
|
||||
|
||||
count(name: string): this;
|
||||
|
||||
default(key: string, value: mixed, description?: string): this;
|
||||
default(defaults: { [key: string]: mixed, ... }): this;
|
||||
default(key: string, value: unknown, description?: string): this;
|
||||
default(defaults: {[key: string]: unknown, ...}): this;
|
||||
|
||||
// Deprecated: use demandOption() and demandCommand() instead.
|
||||
demand(key: string, msg?: string | boolean): this;
|
||||
@@ -174,11 +180,11 @@ declare module "yargs" {
|
||||
min: number,
|
||||
max: number,
|
||||
minMsg?: string,
|
||||
maxMsg?: string
|
||||
maxMsg?: string,
|
||||
): this;
|
||||
|
||||
describe(key: string, description: string): this;
|
||||
describe(describeObject: { [key: string]: string, ... }): this;
|
||||
describe(describeObject: {[key: string]: string, ...}): this;
|
||||
|
||||
detectLocale(shouldDetect: boolean): this;
|
||||
|
||||
@@ -191,11 +197,15 @@ declare module "yargs" {
|
||||
|
||||
exitProcess(enable: boolean): this;
|
||||
|
||||
fail(fn: false | (failureMessage: string, err: Error, yargs: Yargs) => mixed): this;
|
||||
fail(
|
||||
fn:
|
||||
| false
|
||||
| ((failureMessage: string, err: Error, yargs: Yargs) => unknown),
|
||||
): this;
|
||||
|
||||
getCompletion(
|
||||
args: Array<string>,
|
||||
fn: (err: Error | null, completions: Array<string> | void) => void
|
||||
fn: (err: Error | null, completions: Array<string> | void) => void,
|
||||
): Promise<Array<string> | void>;
|
||||
|
||||
global(globals: string | Array<string>, isGlobal?: boolean): this;
|
||||
@@ -209,28 +219,29 @@ declare module "yargs" {
|
||||
hide(key: string): this;
|
||||
|
||||
implies(key: string, value: string | Array<string>): this;
|
||||
implies(keys: { [key: string]: string | Array<string>, ... }): this;
|
||||
implies(keys: {[key: string]: string | Array<string>, ...}): this;
|
||||
|
||||
locale(
|
||||
locale: | "de"
|
||||
| "en"
|
||||
| "es"
|
||||
| "fr"
|
||||
| "hi"
|
||||
| "hu"
|
||||
| "id"
|
||||
| "it"
|
||||
| "ja"
|
||||
| "ko"
|
||||
| "nb"
|
||||
| "pirate"
|
||||
| "pl"
|
||||
| "pt"
|
||||
| "pt_BR"
|
||||
| "ru"
|
||||
| "th"
|
||||
| "tr"
|
||||
| "zh_CN"
|
||||
locale:
|
||||
| 'de'
|
||||
| 'en'
|
||||
| 'es'
|
||||
| 'fr'
|
||||
| 'hi'
|
||||
| 'hu'
|
||||
| 'id'
|
||||
| 'it'
|
||||
| 'ja'
|
||||
| 'ko'
|
||||
| 'nb'
|
||||
| 'pirate'
|
||||
| 'pl'
|
||||
| 'pt'
|
||||
| 'pt_BR'
|
||||
| 'ru'
|
||||
| 'th'
|
||||
| 'tr'
|
||||
| 'zh_CN',
|
||||
): this;
|
||||
locale(): string;
|
||||
|
||||
@@ -246,39 +257,39 @@ declare module "yargs" {
|
||||
number(key: string | Array<string>): this;
|
||||
|
||||
option(key: string, options?: Options): this;
|
||||
option(optionMap: { [key: string]: Options, ... }): this;
|
||||
option(optionMap: {[key: string]: Options, ...}): this;
|
||||
|
||||
options(key: string, options?: Options): this;
|
||||
options(optionMap: { [key: string]: Options, ... }): this;
|
||||
options(optionMap: {[key: string]: Options, ...}): this;
|
||||
|
||||
parse(
|
||||
args?: string | Array<string>,
|
||||
context?: { [key: string]: any, ... },
|
||||
parseCallback?: (err: Error, argv: Argv, output?: string) => void
|
||||
context?: {[key: string]: any, ...},
|
||||
parseCallback?: (err: Error, argv: Argv, output?: string) => void,
|
||||
): Argv | Promise<Argv>;
|
||||
parse(
|
||||
args?: string | Array<string>,
|
||||
parseCallback?: (err: Error, argv: Argv, output?: string) => void
|
||||
parseCallback?: (err: Error, argv: Argv, output?: string) => void,
|
||||
): Argv | Promise<Argv>;
|
||||
|
||||
parseAsync(
|
||||
args?: string | Array<string>,
|
||||
context?: { [key: string]: any, ... },
|
||||
parseCallback?: (err: Error, argv: Argv, output?: string) => void
|
||||
context?: {[key: string]: any, ...},
|
||||
parseCallback?: (err: Error, argv: Argv, output?: string) => void,
|
||||
): Promise<Argv>;
|
||||
parseAsync(
|
||||
args?: string | Array<string>,
|
||||
parseCallback?: (err: Error, argv: Argv, output?: string) => void
|
||||
parseCallback?: (err: Error, argv: Argv, output?: string) => void,
|
||||
): Promise<Argv>;
|
||||
|
||||
parseSync(
|
||||
args?: string | Array<string>,
|
||||
context?: { [key: string]: any, ... },
|
||||
parseCallback?: (err: Error, argv: Argv, output?: string) => void
|
||||
context?: {[key: string]: any, ...},
|
||||
parseCallback?: (err: Error, argv: Argv, output?: string) => void,
|
||||
): Argv;
|
||||
parseSync(
|
||||
args?: string | Array<string>,
|
||||
parseCallback?: (err: Error, argv: Argv, output?: string) => void
|
||||
parseCallback?: (err: Error, argv: Argv, output?: string) => void,
|
||||
): Argv;
|
||||
|
||||
parserConfiguration(configuration: {[key: string]: any, ...}): this;
|
||||
@@ -299,14 +310,14 @@ declare module "yargs" {
|
||||
|
||||
showCompletionScript(): this;
|
||||
|
||||
showHelp(consoleLevel?: "error" | "warn" | "log"): this;
|
||||
showHelp(consoleLevel?: 'error' | 'warn' | 'log'): this;
|
||||
showHelp(printCallback: (usageData: string) => void): this;
|
||||
|
||||
showHelpOnFail(enable: boolean, message?: string): this;
|
||||
|
||||
skipValidation(key: string): this;
|
||||
|
||||
showVersion(consoleLevel?: "error" | "warn" | "log"): this;
|
||||
showVersion(consoleLevel?: 'error' | 'warn' | 'log'): this;
|
||||
showVersion(printCallback: (usageData: string) => void): this;
|
||||
|
||||
strict(enabled?: boolean): this;
|
||||
@@ -319,11 +330,16 @@ declare module "yargs" {
|
||||
|
||||
terminalWidth(): number;
|
||||
|
||||
updateLocale(obj: { [key: string]: string, ... }): this;
|
||||
updateStrings(obj: { [key: string]: string, ... }): this;
|
||||
updateLocale(obj: {[key: string]: string, ...}): this;
|
||||
updateStrings(obj: {[key: string]: string, ...}): this;
|
||||
|
||||
usage(message: string, opts?: { [key: string]: Options, ... }): this;
|
||||
usage(message: string, desc?: string, builder: CommonModuleObject["builder"], handler: CommonModuleObject["handler"]): this;
|
||||
usage(message: string, opts?: {[key: string]: Options, ...}): this;
|
||||
usage(
|
||||
message: string,
|
||||
desc?: string,
|
||||
builder: CommonModuleObject['builder'],
|
||||
handler: CommonModuleObject['handler'],
|
||||
): this;
|
||||
|
||||
version(): this;
|
||||
version(version: string | false): this;
|
||||
@@ -331,7 +347,7 @@ declare module "yargs" {
|
||||
version(
|
||||
option: string | (() => string),
|
||||
description: string | (() => string),
|
||||
version: string
|
||||
version: string,
|
||||
): this;
|
||||
|
||||
wrap(columns: number | null): this;
|
||||
|
||||
+10
-12
@@ -18,20 +18,20 @@ export interface EventSubscription {
|
||||
export interface IEventEmitter<
|
||||
TEventToArgsMap: Readonly<Record<string, ReadonlyArray<UnsafeEventObject>>>,
|
||||
> {
|
||||
addListener<TEvent: $Keys<TEventToArgsMap>>(
|
||||
addListener<TEvent: keyof TEventToArgsMap>(
|
||||
eventType: TEvent,
|
||||
listener: (...args: TEventToArgsMap[TEvent]) => unknown,
|
||||
context?: unknown,
|
||||
): EventSubscription;
|
||||
|
||||
emit<TEvent: $Keys<TEventToArgsMap>>(
|
||||
emit<TEvent: keyof TEventToArgsMap>(
|
||||
eventType: TEvent,
|
||||
...args: TEventToArgsMap[TEvent]
|
||||
): void;
|
||||
|
||||
removeAllListeners<TEvent: $Keys<TEventToArgsMap>>(eventType?: ?TEvent): void;
|
||||
removeAllListeners<TEvent: keyof TEventToArgsMap>(eventType?: ?TEvent): void;
|
||||
|
||||
listenerCount<TEvent: $Keys<TEventToArgsMap>>(eventType: TEvent): number;
|
||||
listenerCount<TEvent: keyof TEventToArgsMap>(eventType: TEvent): number;
|
||||
}
|
||||
|
||||
interface Registration<TArgs> {
|
||||
@@ -83,7 +83,7 @@ export default class EventEmitter<
|
||||
* Registers a listener that is called when the supplied event is emitted.
|
||||
* Returns a subscription that has a `remove` method to undo registration.
|
||||
*/
|
||||
addListener<TEvent: $Keys<TEventToArgsMap>>(
|
||||
addListener<TEvent: keyof TEventToArgsMap>(
|
||||
eventType: TEvent,
|
||||
listener: (...args: TEventToArgsMap[TEvent]) => unknown,
|
||||
context: unknown,
|
||||
@@ -95,7 +95,7 @@ export default class EventEmitter<
|
||||
}
|
||||
const registrations = allocate<
|
||||
TEventToArgsMap,
|
||||
$Keys<TEventToArgsMap>,
|
||||
keyof TEventToArgsMap,
|
||||
TEventToArgsMap[TEvent],
|
||||
>(this.#registry, eventType);
|
||||
const registration: Registration<TEventToArgsMap[TEvent]> = {
|
||||
@@ -116,7 +116,7 @@ export default class EventEmitter<
|
||||
* If a listener modifies the listeners registered for the same event, those
|
||||
* changes will not be reflected in the current invocation of `emit`.
|
||||
*/
|
||||
emit<TEvent: $Keys<TEventToArgsMap>>(
|
||||
emit<TEvent: keyof TEventToArgsMap>(
|
||||
eventType: TEvent,
|
||||
...args: TEventToArgsMap[TEvent]
|
||||
): void {
|
||||
@@ -134,9 +134,7 @@ export default class EventEmitter<
|
||||
/**
|
||||
* Removes all registered listeners.
|
||||
*/
|
||||
removeAllListeners<TEvent: $Keys<TEventToArgsMap>>(
|
||||
eventType?: ?TEvent,
|
||||
): void {
|
||||
removeAllListeners<TEvent: keyof TEventToArgsMap>(eventType?: ?TEvent): void {
|
||||
if (eventType == null) {
|
||||
// $FlowFixMe[incompatible-type]
|
||||
this.#registry = {};
|
||||
@@ -148,7 +146,7 @@ export default class EventEmitter<
|
||||
/**
|
||||
* Returns the number of registered listeners for the supplied event.
|
||||
*/
|
||||
listenerCount<TEvent: $Keys<TEventToArgsMap>>(eventType: TEvent): number {
|
||||
listenerCount<TEvent: keyof TEventToArgsMap>(eventType: TEvent): number {
|
||||
const registrations: ?Set<Registration<TEventToArgsMap[TEvent]>> =
|
||||
this.#registry[eventType];
|
||||
return registrations == null ? 0 : registrations.size;
|
||||
@@ -157,7 +155,7 @@ export default class EventEmitter<
|
||||
|
||||
function allocate<
|
||||
TEventToArgsMap: Readonly<Record<string, ReadonlyArray<UnsafeEventObject>>>,
|
||||
TEvent: $Keys<TEventToArgsMap>,
|
||||
TEvent: keyof TEventToArgsMap,
|
||||
>(
|
||||
registry: Registry<TEventToArgsMap>,
|
||||
eventType: TEvent,
|
||||
|
||||
Reference in new issue
Block a user