Skip to content

Commit 4338af0

Browse files
SamChou19815meta-codesync[bot]
authored andcommitted
Migrate to new variance syntax in libdef files (#57987)
Summary: Pull Request resolved: #57987 Changelog: [Internal] Reviewed By: huntie Differential Revision: D116336455 fbshipit-source-id: 91f8f8a337457045bd321ae638c0c8460d223471
1 parent 42be745 commit 4338af0

4 files changed

Lines changed: 83 additions & 83 deletions

File tree

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,10 @@ declare module '@babel/traverse' {
393393
constructor(path: NodePath<>): Scope;
394394
path: NodePath<>;
395395
block: BabelNode;
396-
+labels: Map<string, NodePath<>>;
397-
+parentBlock: BabelNode;
398-
+parent: Scope;
399-
+hub: HubInterface;
396+
readonly labels: Map<string, NodePath<>>;
397+
readonly parentBlock: BabelNode;
398+
readonly parent: Scope;
399+
readonly hub: HubInterface;
400400
bindings?: {[name: string]: Binding};
401401
references?: {[name: string]: boolean};
402402
globals?: {[name: string]: BabelNode};
@@ -599,7 +599,7 @@ declare module '@babel/traverse' {
599599

600600
declare type Opts = {...};
601601

602-
declare export class NodePath<+TNode extends BabelNode = BabelNode> {
602+
declare export class NodePath<out TNode extends BabelNode = BabelNode> {
603603
parent: BabelNode;
604604
hub: HubInterface;
605605
contexts: Array<TraversalContext>;
@@ -608,7 +608,7 @@ declare module '@babel/traverse' {
608608
shouldStop: boolean;
609609
removed: boolean;
610610
state: unknown;
611-
+opts: Readonly<TraverseOptions<unknown>> | null;
611+
readonly opts: Readonly<TraverseOptions<unknown>> | null;
612612
skipKeys: null | {[key: string]: boolean};
613613
parentPath: ?NodePath<>;
614614
context: TraversalContext;
@@ -621,7 +621,7 @@ declare module '@babel/traverse' {
621621
* work with `NodePath`, e.g. that passing `NodePath<CallExpression>` to a
622622
* `NodePath<Node> works.
623623
*/
624-
+node: TNode;
624+
readonly node: TNode;
625625

626626
parentKey: string;
627627
scope: Scope;
@@ -1731,20 +1731,20 @@ declare module '@babel/traverse' {
17311731
// END GENERATED NODE PATH METHODS
17321732
}
17331733

1734-
declare export type VisitNodeFunction<-TNode extends BabelNode, TState> = (
1734+
declare export type VisitNodeFunction<in TNode extends BabelNode, TState> = (
17351735
path: NodePath<TNode>,
17361736
state: TState,
17371737
) => void;
17381738

17391739
declare export type VisitNodeObject<
1740-
-TNode extends BabelNode,
1740+
in TNode extends BabelNode,
17411741
TState,
17421742
> = Partial<{
17431743
enter(path: NodePath<TNode>, state: TState): void,
17441744
exit(path: NodePath<TNode>, state: TState): void,
17451745
}>;
17461746

1747-
declare export type VisitNode<-TNode extends BabelNode, TState> =
1747+
declare export type VisitNode<in TNode extends BabelNode, TState> =
17481748
VisitNodeFunction<TNode, TState> | VisitNodeObject<TNode, TState>;
17491749

17501750
declare export type Visitor<TState = void> = Readonly<{
@@ -2202,10 +2202,10 @@ declare module '@babel/traverse' {
22022202
parentPath?: ?NodePath<BabelNode>,
22032203
): void,
22042204

2205-
+cache: Cache,
2206-
+visitors: Visitors,
2207-
+verify: Visitors['verify'],
2208-
+explode: Visitors['explode'],
2205+
readonly cache: Cache,
2206+
readonly visitors: Visitors,
2207+
readonly verify: Visitors['verify'],
2208+
readonly explode: Visitors['explode'],
22092209

22102210
cheap<TOptions>(
22112211
node: BabelNode,

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -454,13 +454,13 @@ declare module '@babel/core' {
454454
};
455455

456456
declare export class ConfigItem {
457-
+value: PluginObj<unknown> | (() => PluginObj<unknown>);
458-
+options: EntryOptions;
459-
+dirname: string;
460-
+name: string | void;
461-
+file: {
462-
+request: string,
463-
+resolved: string,
457+
readonly value: PluginObj<unknown> | (() => PluginObj<unknown>);
458+
readonly options: EntryOptions;
459+
readonly dirname: string;
460+
readonly name: string | void;
461+
readonly file: {
462+
readonly request: string,
463+
readonly resolved: string,
464464
} | void;
465465

466466
constructor(descriptor: UnloadedDescriptor): ConfigItem;
@@ -1110,12 +1110,12 @@ declare module '@babel/core' {
11101110
declare type ValidatedOptions = BabelCoreOptions;
11111111

11121112
declare class PartialConfig {
1113-
+options: Readonly<ValidatedOptions>;
1114-
+babelrc: string | void;
1115-
+babelignore: string | void;
1116-
+config: string | void;
1117-
+files: ReadonlySet<string>;
1118-
+fileHandling: 'ignored' | 'transpile' | 'unsupported';
1113+
readonly options: Readonly<ValidatedOptions>;
1114+
readonly babelrc: string | void;
1115+
readonly babelignore: string | void;
1116+
readonly config: string | void;
1117+
readonly files: ReadonlySet<string>;
1118+
readonly fileHandling: 'ignored' | 'transpile' | 'unsupported';
11191119

11201120
constructor(options: ValidatedOptions): PartialConfig;
11211121

packages/react-native/flow/HermesInternalType.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ declare type $HermesInternalType = {
2626
// All members are optional because they may not exist when OTA'd to older
2727
// VMs.
2828

29-
+getNumGCs?: () => number,
30-
+getGCTime?: () => number,
31-
+getNativeCallTime?: () => number,
32-
+getNativeCallCount?: () => number,
33-
+getGCCPUTime?: () => number,
29+
readonly getNumGCs?: () => number,
30+
readonly getGCTime?: () => number,
31+
readonly getNativeCallTime?: () => number,
32+
readonly getNativeCallCount?: () => number,
33+
readonly getGCCPUTime?: () => number,
3434

3535
/**
3636
* Hermes can embed an "epilogue" to the bytecode file with arbitrary bytes.
@@ -39,7 +39,7 @@ declare type $HermesInternalType = {
3939
* Calling this function will return all such epilogues and convert the
4040
* bytes to numbers in the range of 0-255.
4141
*/
42-
+getEpilogues?: () => Array<Array<number>>,
42+
readonly getEpilogues?: () => Array<Array<number>>,
4343

4444
/**
4545
* Query the VM for various statistics about performance.
@@ -48,15 +48,15 @@ declare type $HermesInternalType = {
4848
* @return An object that maps strings to various types of performance
4949
* statistics.
5050
*/
51-
+getInstrumentedStats?: () => {[string]: number | string, ...},
51+
readonly getInstrumentedStats?: () => {[string]: number | string, ...},
5252

5353
/**
5454
* Query the VM for any sort of runtime properties that it wants to report.
5555
* There are no guarantees about what keys exist in it, but they can be
5656
* printed for informational purposes.
5757
* @return An object that maps strings to various types of runtime properties.
5858
*/
59-
+getRuntimeProperties?: () => {
59+
readonly getRuntimeProperties?: () => {
6060
'OSS Release Version': string,
6161
Build: string,
6262
[string]: unknown,
@@ -69,7 +69,7 @@ declare type $HermesInternalType = {
6969
* This can be called several times but will have no effect after the first
7070
* call.
7171
*/
72-
+ttiReached?: () => void,
72+
readonly ttiReached?: () => void,
7373

7474
/**
7575
* Tell Hermes that at this point the surface has transitioned from TTRC to
@@ -78,20 +78,20 @@ declare type $HermesInternalType = {
7878
* This can be called several times but will have no effect after the first
7979
* call.
8080
*/
81-
+ttrcReached?: () => void,
81+
readonly ttrcReached?: () => void,
8282

8383
/**
8484
* Query the VM to see whether or not it enabled Promise.
8585
*/
86-
+hasPromise?: () => boolean,
86+
readonly hasPromise?: () => boolean,
8787

8888
/**
8989
* Enable promise rejection tracking with the given options.
9090
* The API mirrored the `promise` npm package, therefore it's typed same as
9191
* the `enable` function of module `promise/setimmediate/rejection-tracking`
9292
* declared in ./flow-typed/npm/promise_v8.x.x.js.
9393
*/
94-
+enablePromiseRejectionTracker?: (
94+
readonly enablePromiseRejectionTracker?: (
9595
options: ?{
9696
whitelist?: ?Array<unknown>,
9797
allRejections?: ?boolean,
@@ -103,12 +103,12 @@ declare type $HermesInternalType = {
103103
/**
104104
* Query the VM to see whether or not it use the engine Job queue.
105105
*/
106-
+useEngineQueue?: () => boolean,
106+
readonly useEngineQueue?: () => boolean,
107107

108108
/**
109109
* Enqueue a JavaScript callback function as a Job into the engine Job queue.
110110
*/
111-
+enqueueJob?: <TArguments extends Array<unknown>>(
111+
readonly enqueueJob?: <TArguments extends Array<unknown>>(
112112
jobCallback: (...args: TArguments) => unknown,
113113
) => void,
114114
};

packages/react-native/flow/global.js

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -18,70 +18,70 @@
1818
// $FlowFixMe[libdef-override]
1919
declare var global: {
2020
// setUpGlobals
21-
+window: typeof global,
22-
+self: typeof global,
23-
+process: {
24-
+env: {
25-
+NODE_ENV: 'development' | 'production',
21+
readonly window: typeof global,
22+
readonly self: typeof global,
23+
readonly process: {
24+
readonly env: {
25+
readonly NODE_ENV: 'development' | 'production',
2626
},
27-
+argv?: ReadonlyArray<string>,
27+
readonly argv?: ReadonlyArray<string>,
2828
},
2929

3030
// setUpPerformance
31-
+performance: Performance,
31+
readonly performance: Performance,
3232

3333
// setUpXHR
34-
+XMLHttpRequest: typeof XMLHttpRequest,
35-
+FormData: typeof FormData,
36-
+fetch: typeof fetch,
37-
+Headers: typeof Headers,
38-
+Request: typeof Request,
39-
+Response: typeof Response,
40-
+WebSocket: typeof WebSocket,
41-
+Blob: typeof Blob,
42-
+File: typeof File,
43-
+FileReader: typeof FileReader,
44-
+URL: typeof URL,
45-
+URLSearchParams: typeof URLSearchParams,
46-
+AbortController: typeof AbortController,
47-
+AbortSignal: typeof AbortSignal,
34+
readonly XMLHttpRequest: typeof XMLHttpRequest,
35+
readonly FormData: typeof FormData,
36+
readonly fetch: typeof fetch,
37+
readonly Headers: typeof Headers,
38+
readonly Request: typeof Request,
39+
readonly Response: typeof Response,
40+
readonly WebSocket: typeof WebSocket,
41+
readonly Blob: typeof Blob,
42+
readonly File: typeof File,
43+
readonly FileReader: typeof FileReader,
44+
readonly URL: typeof URL,
45+
readonly URLSearchParams: typeof URLSearchParams,
46+
readonly AbortController: typeof AbortController,
47+
readonly AbortSignal: typeof AbortSignal,
4848

4949
// setUpAlert
50-
+alert: typeof alert,
50+
readonly alert: typeof alert,
5151

5252
// setUpNavigator
53-
+navigator: {
54-
+product: 'ReactNative',
55-
+appName?: ?string,
53+
readonly navigator: {
54+
readonly product: 'ReactNative',
55+
readonly appName?: ?string,
5656
...
5757
},
5858

5959
// setUpTimers
60-
+setInterval: typeof setInterval,
61-
+clearInterval: typeof clearInterval,
62-
+setTimeout: typeof setTimeout,
63-
+clearTimeout: typeof clearTimeout,
64-
+requestAnimationFrame: typeof requestAnimationFrame,
65-
+cancelAnimationFrame: typeof cancelAnimationFrame,
66-
+requestIdleCallback: typeof requestIdleCallback,
67-
+cancelIdleCallback: typeof cancelIdleCallback,
68-
+queueMicrotask: typeof queueMicrotask,
69-
+setImmediate: typeof setImmediate,
70-
+clearImmediate: typeof clearImmediate,
60+
readonly setInterval: typeof setInterval,
61+
readonly clearInterval: typeof clearInterval,
62+
readonly setTimeout: typeof setTimeout,
63+
readonly clearTimeout: typeof clearTimeout,
64+
readonly requestAnimationFrame: typeof requestAnimationFrame,
65+
readonly cancelAnimationFrame: typeof cancelAnimationFrame,
66+
readonly requestIdleCallback: typeof requestIdleCallback,
67+
readonly cancelIdleCallback: typeof cancelIdleCallback,
68+
readonly queueMicrotask: typeof queueMicrotask,
69+
readonly setImmediate: typeof setImmediate,
70+
readonly clearImmediate: typeof clearImmediate,
7171

7272
// Polyfills
73-
+console: typeof console,
73+
readonly console: typeof console,
7474

7575
// JavaScript environments specific
76-
+HermesInternal: ?$HermesInternalType,
76+
readonly HermesInternal: ?$HermesInternalType,
7777

7878
// Internal-specific
79-
+__DEV__?: boolean,
80-
+RN$Bridgeless?: boolean,
79+
readonly __DEV__?: boolean,
80+
readonly RN$Bridgeless?: boolean,
8181

8282
// setupDOM
83-
+DOMRect: typeof DOMRect,
84-
+DOMRectReadOnly: typeof DOMRectReadOnly,
83+
readonly DOMRect: typeof DOMRect,
84+
readonly DOMRectReadOnly: typeof DOMRectReadOnly,
8585

8686
// Undeclared properties are implicitly `any`.
8787
[string | symbol]: any,

0 commit comments

Comments
 (0)