Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions flow-typed/environment/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ declare class crypto$Hash extends stream$Duplex {
data: string | Buffer,
input_encoding?: 'utf8' | 'ascii' | 'latin1' | 'binary',
): crypto$Hash;
copy(options?: mixed): crypto$Hash;
copy(options?: unknown): crypto$Hash;
}

declare class crypto$Hmac extends stream$Duplex {
Expand Down Expand Up @@ -703,7 +703,7 @@ declare class crypto$KeyObject {
format: 'der',
}>,
): Buffer;
export(options: Readonly<{format: 'jwk'}>): mixed;
export(options: Readonly<{format: 'jwk'}>): unknown;
equals(otherKeyObject: crypto$KeyObject): boolean;
}

Expand Down Expand Up @@ -739,7 +739,7 @@ declare class crypto$X509Certificate {
checkIssued(otherCert: crypto$X509Certificate): boolean;
checkPrivateKey(privateKey: crypto$KeyObject): boolean;
toJSON(): string;
toLegacyObject(): mixed;
toLegacyObject(): unknown;
toString(): string;
verify(publicKey: crypto$KeyObject): boolean;
}
Expand Down Expand Up @@ -930,10 +930,10 @@ declare module 'crypto' {
encoding: buffer$Encoding,
): crypto$KeyObject;
declare function createPublicKey(
key: string | Buffer | crypto$KeyObject | mixed,
key: string | Buffer | crypto$KeyObject | unknown,
): crypto$KeyObject;
declare function createPrivateKey(
key: string | Buffer | mixed,
key: string | Buffer | unknown,
): crypto$KeyObject;
declare function generateKeyPair(
type:
Expand All @@ -945,7 +945,7 @@ declare module 'crypto' {
| 'ed448'
| 'x25519'
| 'x448',
options: mixed,
options: unknown,
callback: (
err: ?Error,
publicKey: crypto$KeyObject,
Expand All @@ -962,7 +962,7 @@ declare module 'crypto' {
| 'ed448'
| 'x25519'
| 'x448',
options: mixed,
options: unknown,
): {publicKey: crypto$KeyObject, privateKey: crypto$KeyObject, ...};
declare function generateKey(
type: 'hmac' | 'aes',
Expand Down Expand Up @@ -2011,8 +2011,8 @@ declare module 'fs' {
| Buffer
| Uint8Array
| DataView
| AsyncIterable<mixed>
| Iterable<mixed>
| AsyncIterable<unknown>
| Iterable<unknown>
| stream$Readable,
options: WriteOptions | string,
) => Promise<void>;
Expand Down Expand Up @@ -2908,17 +2908,19 @@ declare module 'perf_hooks' {
+entryType: EntryType;
+name: string;
+startTime: number;
+detail?: mixed;
toJSON(): mixed;
+detail?: unknown;
toJSON(): unknown;
}

declare export class PerformanceMark<T = mixed> extends PerformanceEntry {
declare export class PerformanceMark<T = unknown> extends PerformanceEntry {
+entryType: 'mark';
+duration: 0;
+detail?: T;
}

declare export class PerformanceMeasure<T = mixed> extends PerformanceEntry {
declare export class PerformanceMeasure<T = unknown>
extends PerformanceEntry
{
+entryType: 'measure';
+detail?: T;
}
Expand Down Expand Up @@ -2987,12 +2989,12 @@ declare module 'perf_hooks' {
+active: number,
};

declare export type PerformanceMarkOptions<T = mixed> = Readonly<{
declare export type PerformanceMarkOptions<T = unknown> = Readonly<{
detail?: T,
startTime?: number,
}>;

declare export type PerformanceMeasureOptions<T = mixed> = Readonly<{
declare export type PerformanceMeasureOptions<T = unknown> = Readonly<{
detail?: T,
duration?: number,
end?: number | string,
Expand Down Expand Up @@ -3023,11 +3025,11 @@ declare module 'perf_hooks' {
now(): number;
setResourceTimingBufferSize(maxSize: number): void;
+timeOrigin: number;
timerify<TArgs: Iterable<mixed>, TReturn>(
timerify<TArgs: Iterable<unknown>, TReturn>(
fn: (...TArgs) => TReturn,
options?: Readonly<{histogram?: RecordableHistogram}>,
): (...TArgs) => TReturn;
toJSON(): mixed;
toJSON(): unknown;
}

declare export var performance: Performance;
Expand Down Expand Up @@ -3720,20 +3722,20 @@ declare module 'timers' {
// [key: $SymbolDispose]: () => void;
}

declare export function setTimeout<TArgs: Iterable<mixed>>(
callback: (...args: TArgs) => mixed,
declare export function setTimeout<TArgs: Iterable<unknown>>(
callback: (...args: TArgs) => unknown,
delay?: number,
...args: TArgs
): Timeout;

declare export function setInterval<TArgs: Iterable<mixed>>(
callback: (...args: TArgs) => mixed,
declare export function setInterval<TArgs: Iterable<unknown>>(
callback: (...args: TArgs) => unknown,
delay?: number,
...args: TArgs
): Timeout;

declare export function setImmediate<TArgs: Iterable<mixed>>(
callback: (...args: TArgs) => mixed,
declare export function setImmediate<TArgs: Iterable<unknown>>(
callback: (...args: TArgs) => unknown,
...args: TArgs
): Immediate;

Expand Down
10 changes: 5 additions & 5 deletions flow-typed/npm/babel-traverse_v7.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,24 +556,24 @@ declare module '@babel/traverse' {
* Check whether we have the input `key`. If the `key` references an array then we check
* if the array has any items, otherwise we just check if it's falsy.
*/
has(key: $Keys<TNode>): boolean;
has(key: keyof TNode): boolean;

isStatic(): boolean;

/**
* Alias of `has`.
*/
is(key: $Keys<TNode>): boolean;
is(key: keyof TNode): boolean;

/**
* Opposite of `has`.
*/
isnt(key: $Keys<TNode>): boolean;
isnt(key: keyof TNode): boolean;

/**
* Check whether the path node `key` strict equals `value`.
*/
equals(key: $Keys<TNode>, value: any): boolean;
equals(key: keyof TNode, value: any): boolean;

/**
* Check the type against our stored internal type of the node. This is handy when a node has
Expand Down Expand Up @@ -724,7 +724,7 @@ declare module '@babel/traverse' {

getAllPrevSiblings(): Array<NodePath<>>;

get<TKey: $Keys<TNode>>(
get<TKey: keyof TNode>(
key: TKey,
context?: boolean | TraversalContext,
): TNode[TKey] extends BabelNode ? NodePath<> : Array<NodePath<>>;
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/rxjs_v6.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -2193,10 +2193,10 @@ declare module 'rxjs/operators' {
): rxjs$MonoTypeOperatorFunction<T>;

declare export function distinctUntilKeyChanged<T>(
key: $Keys<T>,
key: keyof T,
): rxjs$MonoTypeOperatorFunction<T>;

declare export function distinctUntilKeyChanged<T, K: $Keys<T>>(
declare export function distinctUntilKeyChanged<T, K: keyof T>(
key: K,
compare: (x: unknown, y: unknown) => boolean,
): rxjs$MonoTypeOperatorFunction<T>;
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-middleware/src/inspector-proxy/Device.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ export default class Device {
/**
* Returns `true` if a page supports the given target capability flag.
*/
#pageHasCapability(page: Page, flag: $Keys<TargetCapabilityFlags>): boolean {
#pageHasCapability(page: Page, flag: keyof TargetCapabilityFlags): boolean {
return page.capabilities[flag] === true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ import type {JSONSerializable} from '../types';
import type {Commands, Events} from './protocol';

// Note: A CDP event is a JSON-RPC notification with no `id` member.
export type CDPEvent<TEvent: $Keys<Events> = 'unknown'> = {
export type CDPEvent<TEvent: keyof Events = 'unknown'> = {
method: TEvent,
params: Events[TEvent],
};

export type CDPRequest<TCommand: $Keys<Commands> = 'unknown'> = {
export type CDPRequest<TCommand: keyof Commands = 'unknown'> = {
method: TCommand,
params: Commands[TCommand]['paramsType'],
id: number,
};

export type CDPResponse<TCommand: $Keys<Commands> = 'unknown'> =
export type CDPResponse<TCommand: keyof Commands = 'unknown'> =
| {
result: Commands[TCommand]['resultType'],
id: number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ type PassThroughProps = Readonly<{
passthroughAnimatedPropExplicitValues?: ViewProps | null,
}>;

type LooseOmit<O: interface {}, K: $Keys<$FlowFixMe>> = Pick<
type LooseOmit<O: interface {}, K: keyof $FlowFixMe> = Pick<
O,
Exclude<$Keys<O>, K>,
Exclude<keyof O, K>,
>;

export type AnimatedProps<Props: {...}> = LooseOmit<
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/AppState/AppState.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type AppStateEventDefinitions = {
focus: [],
};

export type AppStateEvent = $Keys<AppStateEventDefinitions>;
export type AppStateEvent = keyof AppStateEventDefinitions;

type NativeAppStateEventDefinitions = {
appStateDidChange: [{app_state: AppStateStatus}],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,28 @@ type AccessibilityEventTypes =
| 'windowStateChange';

// Mapping of public event names to platform-specific event names.
const EventNames: Map<
$Keys<AccessibilityEventDefinitions>,
string,
> = Platform.OS === 'android'
? new Map([
['change', 'touchExplorationDidChange'],
['reduceMotionChanged', 'reduceMotionDidChange'],
['highTextContrastChanged', 'highTextContrastDidChange'],
['screenReaderChanged', 'touchExplorationDidChange'],
['accessibilityServiceChanged', 'accessibilityServiceDidChange'],
['invertColorsChanged', 'invertColorDidChange'],
['grayscaleChanged', 'grayscaleModeDidChange'],
])
: new Map([
['announcementFinished', 'announcementFinished'],
['boldTextChanged', 'boldTextChanged'],
['change', 'screenReaderChanged'],
['grayscaleChanged', 'grayscaleChanged'],
['invertColorsChanged', 'invertColorsChanged'],
['reduceMotionChanged', 'reduceMotionChanged'],
['reduceTransparencyChanged', 'reduceTransparencyChanged'],
['screenReaderChanged', 'screenReaderChanged'],
['darkerSystemColorsChanged', 'darkerSystemColorsChanged'],
]);
const EventNames: Map<keyof AccessibilityEventDefinitions, string> =
Platform.OS === 'android'
? new Map([
['change', 'touchExplorationDidChange'],
['reduceMotionChanged', 'reduceMotionDidChange'],
['highTextContrastChanged', 'highTextContrastDidChange'],
['screenReaderChanged', 'touchExplorationDidChange'],
['accessibilityServiceChanged', 'accessibilityServiceDidChange'],
['invertColorsChanged', 'invertColorDidChange'],
['grayscaleChanged', 'grayscaleModeDidChange'],
])
: new Map([
['announcementFinished', 'announcementFinished'],
['boldTextChanged', 'boldTextChanged'],
['change', 'screenReaderChanged'],
['grayscaleChanged', 'grayscaleChanged'],
['invertColorsChanged', 'invertColorsChanged'],
['reduceMotionChanged', 'reduceMotionChanged'],
['reduceTransparencyChanged', 'reduceTransparencyChanged'],
['screenReaderChanged', 'screenReaderChanged'],
['darkerSystemColorsChanged', 'darkerSystemColorsChanged'],
]);

/**
* Sometimes it's useful to know whether or not the device has a screen reader
Expand Down Expand Up @@ -426,7 +424,7 @@ const AccessibilityInfo = {
*
* See https://reactnative.dev/docs/accessibilityinfo#addeventlistener
*/
addEventListener<K: $Keys<AccessibilityEventDefinitions>>(
addEventListener<K: keyof AccessibilityEventDefinitions>(
eventName: K,
// $FlowFixMe[incompatible-type] - Flow bug with unions and generics (T128099423)
handler: (...AccessibilityEventDefinitions[K]) => void,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import dismissKeyboard from '../../Utilities/dismissKeyboard';
import Platform from '../../Utilities/Platform';
import NativeKeyboardObserver from './NativeKeyboardObserver';

export type KeyboardEventName = $Keys<KeyboardEventDefinitions>;
export type KeyboardEventName = keyof KeyboardEventDefinitions;

export type KeyboardEventEasing =
| 'easeIn'
Expand Down Expand Up @@ -146,7 +146,7 @@ class KeyboardImpl {
*
* @param {function} callback function to be called when the event fires.
*/
addListener<K: $Keys<KeyboardEventDefinitions>>(
addListener<K: keyof KeyboardEventDefinitions>(
eventType: K,
listener: (...KeyboardEventDefinitions[K]) => unknown,
context?: unknown,
Expand All @@ -159,7 +159,7 @@ class KeyboardImpl {
*
* @param {string} eventType The native event string listeners are watching which will be removed.
*/
removeAllListeners<K: $Keys<KeyboardEventDefinitions>>(eventType: ?K): void {
removeAllListeners<K: keyof KeyboardEventDefinitions>(eventType: ?K): void {
this._emitter.removeAllListeners(eventType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type {ProgressBarAndroidProps};
// of ProgressBarAndroidProps. TS's Omit does not distribute over unions, so
// we define our own version which does. This does not affect Flow.
// $FlowExpectedError[unclear-type]
type Omit<T, K> = T extends any ? Pick<T, Exclude<$Keys<T>, K>> : T;
type Omit<T, K> = T extends any ? Pick<T, Exclude<keyof T, K>> : T;

/**
* ProgressBarAndroid has been extracted from react-native core and will be removed in a future release.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as React from 'react';
/**
* Status bar style
*/
export type StatusBarStyle = $Keys<{
export type StatusBarStyle = keyof {
/**
* Default status bar style (dark for iOS, light for Android)
*/
Expand All @@ -34,12 +34,12 @@ export type StatusBarStyle = $Keys<{
*/
'dark-content': string,
...
}>;
};

/**
* Status bar animation
*/
export type StatusBarAnimation = $Keys<{
export type StatusBarAnimation = keyof {
/**
* No animation
*/
Expand All @@ -53,7 +53,7 @@ export type StatusBarAnimation = $Keys<{
*/
slide: string,
...
}>;
};

export type StatusBarPropsAndroid = Readonly<{
/**
Expand Down
Loading
Loading