Redo modern syntax rollout in react-native (#57034)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/57034

With D107165685, it should work this time.

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D107111468

fbshipit-source-id: 326b2911088d7c87c3564a578125eeaab9d0b8cc
This commit is contained in:
Sam Zhou
2026-06-03 07:21:54 -07:00
committed by meta-codesync[bot]
parent 64c9663152
commit e0ed406590
234 changed files with 1740 additions and 1563 deletions
+10 -10
View File
@@ -14,16 +14,16 @@
export type AssetDestPathResolver = 'android' | 'generic';
export type PackagerAsset = {
+__packager_asset: boolean,
+fileSystemLocation: string,
+httpServerLocation: string,
+width: ?number,
+height: ?number,
+scales: Array<number>,
+hash: string,
+name: string,
+type: string,
+resolver?: AssetDestPathResolver,
readonly __packager_asset: boolean,
readonly fileSystemLocation: string,
readonly httpServerLocation: string,
readonly width: ?number,
readonly height: ?number,
readonly scales: Array<number>,
readonly hash: string,
readonly name: string,
readonly type: string,
readonly resolver?: AssetDestPathResolver,
...
};
*/
@@ -84,7 +84,7 @@ export class DebuggerAgent {
export class DebuggerMock extends DebuggerAgent {
// Empty handlers
+handle: JestMockFn<[message: JSONSerializable], void> = jest.fn();
readonly handle: JestMockFn<[message: JSONSerializable], void> = jest.fn();
__handle(message: JSONSerializable): void {
this.handle(message);
@@ -98,16 +98,18 @@ export class DeviceAgent {
export class DeviceMock extends DeviceAgent {
// Empty handlers
+connect: JestMockFn<[message: ConnectRequest], void> = jest.fn();
+disconnect: JestMockFn<[message: DisconnectRequest], void> = jest.fn();
+getPages: JestMockFn<
readonly connect: JestMockFn<[message: ConnectRequest], void> = jest.fn();
readonly disconnect: JestMockFn<[message: DisconnectRequest], void> =
jest.fn();
readonly getPages: JestMockFn<
[message: GetPagesRequest],
| GetPagesResponse['payload']
| Promise<GetPagesResponse['payload'] | void>
| void,
> = jest.fn();
+wrappedEvent: JestMockFn<[message: WrappedEventToDevice], void> = jest.fn();
+wrappedEventParsed: JestMockFn<
readonly wrappedEvent: JestMockFn<[message: WrappedEventToDevice], void> =
jest.fn();
readonly wrappedEventParsed: JestMockFn<
[
payload: {
...WrappedEventToDevice['payload'],
@@ -25,7 +25,7 @@ const PAGES_POLLING_DELAY = 2100;
jest.useFakeTimers();
async function setupDevice(
serverRef: {+serverBaseWsUrl: string, ...},
serverRef: {readonly serverBaseWsUrl: string, ...},
signal: AbortSignal,
) {
const device = await createDeviceMock(
@@ -138,7 +138,7 @@ export default class Device {
// Logging reporting batches of cdp messages
#cdpDebugLogging: CdpDebugLogging;
+#experiments: Experiments;
readonly #experiments: Experiments;
constructor(deviceOptions: DeviceOptions) {
this.#experiments = deviceOptions.experiments;
@@ -93,7 +93,7 @@ export default class InspectorProxy implements InspectorProxyQueries {
#eventReporter: ?EventReporter;
+#experiments: Experiments;
readonly #experiments: Experiments;
// custom message handler factory allowing implementers to handle unsupported CDP messages.
#customMessageHandler: ?CreateCustomMessageHandlerFn;
@@ -156,11 +156,11 @@ export type JSONSerializable =
| string
| null
| ReadonlyArray<JSONSerializable>
| {+[string]: JSONSerializable};
| {readonly [string]: JSONSerializable};
export type DeepReadOnly<T> =
T extends ReadonlyArray<infer V>
? ReadonlyArray<DeepReadOnly<V>>
: T extends {...}
? {+[K in keyof T]: DeepReadOnly<T[K]>}
? {readonly [K in keyof T]: DeepReadOnly<T[K]>}
: T;
@@ -27,7 +27,7 @@ export interface DevToolLauncher {
* the host of dev-middleware. Implementations are responsible for rewriting
* this as necessary where the server is remote.
*/
+launchDebuggerAppWindow: (url: string) => Promise<void>;
readonly launchDebuggerAppWindow: (url: string) => Promise<void>;
/**
* Attempt to open a debugger frontend URL in a standalone shell window
@@ -47,7 +47,10 @@ export interface DevToolLauncher {
* the host of dev-middleware. Implementations are responsible for rewriting
* this as necessary where the server is remote.
*/
+launchDebuggerShell?: (url: string, windowKey: string) => Promise<void>;
readonly launchDebuggerShell?: (
url: string,
windowKey: string,
) => Promise<void>;
/**
* Attempt to prepare the debugger shell for use and returns a coded result
@@ -60,5 +63,5 @@ export interface DevToolLauncher {
* SHOULD NOT return a rejecting promise in any case, and instead SHOULD report
* errors via the returned result object.
*/
+prepareDebuggerShell?: () => Promise<DebuggerShellPreparationResult>;
readonly prepareDebuggerShell?: () => Promise<DebuggerShellPreparationResult>;
}
@@ -15,7 +15,7 @@ export interface ReadonlyURLSearchParams {
get(name: string): string | null;
getAll(name: string): Array<string>;
has(name: string, value?: string): boolean;
+size: number;
readonly size: number;
entries(): Iterator<[string, string]>;
keys(): Iterator<string>;
values(): Iterator<string>;
@@ -37,18 +37,18 @@ export interface ReadonlyURLSearchParams {
* Used for URLs passed between module boundaries.
*/
export interface ReadonlyURL {
+hash: string;
+host: string;
+hostname: string;
+href: string;
+origin: string;
+password: string;
+pathname: string;
+port: string;
+protocol: string;
+search: string;
+searchParams: ReadonlyURLSearchParams;
+username: string;
readonly hash: string;
readonly host: string;
readonly hostname: string;
readonly href: string;
readonly origin: string;
readonly password: string;
readonly pathname: string;
readonly port: string;
readonly protocol: string;
readonly search: string;
readonly searchParams: ReadonlyURLSearchParams;
readonly username: string;
toString(): string;
toJSON(): string;
}
@@ -16,9 +16,12 @@ export type ArrayType = string;
type AnotherArray = Array<ArrayType>;
export interface Spec extends TurboModule {
+getArray: (a: Array<any>) => Array<string>;
+getReadOnlyArray: (a: Array<any>) => ReadonlyArray<string>;
+getArrayWithAlias: (a: AnotherArray, b: Array<ArrayType>) => AnotherArray;
readonly getArray: (a: Array<any>) => Array<string>;
readonly getReadOnlyArray: (a: Array<any>) => ReadonlyArray<string>;
readonly getArrayWithAlias: (
a: AnotherArray,
b: Array<ArrayType>,
) => AnotherArray;
}
export default TurboModuleRegistry.getEnforcing<Spec>(
@@ -16,8 +16,8 @@ export type Boolean = boolean;
type AnotherBoolean = Boolean;
export interface Spec extends TurboModule {
+getBoolean: (arg: boolean) => boolean;
+getBooleanWithAlias: (arg: Boolean) => AnotherBoolean;
readonly getBoolean: (arg: boolean) => boolean;
readonly getBooleanWithAlias: (arg: Boolean) => AnotherBoolean;
}
export default TurboModuleRegistry.getEnforcing<Spec>(
@@ -16,8 +16,8 @@ export type String = string;
type CB = (value: String) => void;
export interface Spec extends TurboModule {
+getValueWithCallback: (callback: (value: string) => void) => void;
+getValueWithCallbackWithAlias: (c: CB) => void;
readonly getValueWithCallback: (callback: (value: string) => void) => void;
readonly getValueWithCallbackWithAlias: (c: CB) => void;
}
export default TurboModuleRegistry.getEnforcing<Spec>(
@@ -49,17 +49,17 @@ export type StateTypeWithEnums = {
};
export interface Spec extends TurboModule {
+getStatusRegular: (statusProp: StateType) => StatusRegularEnum;
+getStatusStr: (statusProp: StateType) => StatusStrEnum;
+getStatusNum: (statusProp: StateType) => StatusNumEnum;
+getStatusLowerCase: (statusProp: StateType) => StatusLowerCaseEnum;
+getStateType: (
readonly getStatusRegular: (statusProp: StateType) => StatusRegularEnum;
readonly getStatusStr: (statusProp: StateType) => StatusStrEnum;
readonly getStatusNum: (statusProp: StateType) => StatusNumEnum;
readonly getStatusLowerCase: (statusProp: StateType) => StatusLowerCaseEnum;
readonly getStateType: (
a: StatusRegularEnum,
b: StatusStrEnum,
c: StatusNumEnum,
d: StatusLowerCaseEnum,
) => StateType;
+getStateTypeWithEnums: (
readonly getStateTypeWithEnums: (
paramOfTypeWithEnums: StateTypeWithEnums,
) => StateTypeWithEnums;
}
@@ -13,12 +13,12 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+getBool: (a: ?boolean) => ?boolean;
+getNumber: (a: ?number) => ?number;
+getString: (a: ?number) => ?string;
+getArray: (a: ?Array<any>) => ?Array<any>;
+getObject: (a: ?Object) => ?Object;
+getValueWithPromise: () => ?Promise<string>;
readonly getBool: (a: ?boolean) => ?boolean;
readonly getNumber: (a: ?number) => ?number;
readonly getString: (a: ?number) => ?string;
readonly getArray: (a: ?Array<any>) => ?Array<any>;
readonly getObject: (a: ?Object) => ?Object;
readonly getValueWithPromise: () => ?Promise<string>;
}
export default TurboModuleRegistry.getEnforcing<Spec>(
@@ -16,8 +16,8 @@ export type Number = number;
type AnotherNumber = Number;
export interface Spec extends TurboModule {
+getNumber: (arg: number) => number;
+getNumberWithAlias: (arg: Number) => AnotherNumber;
readonly getNumber: (arg: number) => number;
readonly getNumberWithAlias: (arg: Number) => AnotherNumber;
}
export default TurboModuleRegistry.getEnforcing<Spec>(
@@ -16,10 +16,12 @@ export type GenericObject = Object;
type AnotherGenericObject = GenericObject;
export interface Spec extends TurboModule {
+getGenericObject: (arg: Object) => Object;
+getGenericObjectReadOnly: (arg: Object) => Readonly<{a: string}>;
+getGenericObjectWithAlias: (arg: GenericObject) => AnotherGenericObject;
+difficultObject: (A: {
readonly getGenericObject: (arg: Object) => Object;
readonly getGenericObjectReadOnly: (arg: Object) => Readonly<{a: string}>;
readonly getGenericObjectWithAlias: (
arg: GenericObject,
) => AnotherGenericObject;
readonly difficultObject: (A: {
D: boolean,
E: {
D: boolean,
@@ -40,7 +42,7 @@ export interface Spec extends TurboModule {
},
F: string,
};
+getConstants: () => {
readonly getConstants: () => {
D: boolean,
E: {
D: boolean,
@@ -13,7 +13,7 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+getConstants: () => {
readonly getConstants: () => {
D?: ?boolean,
A?: Array<any>,
E?: ?{
@@ -22,10 +22,10 @@ export type SomeObj = {
export type PartialSomeObj = Partial<SomeObj>;
export interface Spec extends TurboModule {
+getSomeObj: () => SomeObj;
+getPartialSomeObj: () => Partial<SomeObj>;
+getSomeObjFromPartialSomeObj: (value: Partial<SomeObj>) => SomeObj;
+getPartialPartial: (
readonly getSomeObj: () => SomeObj;
readonly getPartialSomeObj: () => Partial<SomeObj>;
readonly getSomeObjFromPartialSomeObj: (value: Partial<SomeObj>) => SomeObj;
readonly getPartialPartial: (
value1: Partial<SomeObj>,
value2: PartialSomeObj,
) => SomeObj;
@@ -16,8 +16,8 @@ export type String = string;
type AnotherPromise = Promise<String>;
export interface Spec extends TurboModule {
+getValueWithPromise: (error: boolean) => Promise<string>;
+getValueWithPromiseWithAlias: (arg: String) => AnotherPromise;
readonly getValueWithPromise: (error: boolean) => Promise<string>;
readonly getValueWithPromiseWithAlias: (arg: String) => AnotherPromise;
}
export default TurboModuleRegistry.getEnforcing<Spec>(
@@ -21,23 +21,23 @@ type Animal = {
export interface Spec extends TurboModule {
// Exported methods.
+getConstants: () => {
readonly getConstants: () => {
const1: boolean,
const2: number,
const3: string,
};
+voidFunc: () => void;
+getBool: (arg: boolean) => boolean;
+getNumber: (arg: number) => number;
+getString: (arg: string) => string;
+getArray: (arg: Array<any>) => Array<any>;
+getObject: (arg: Object) => Object;
+getObjectShape: (arg: {prop: number}) => {prop: number};
+getAlias: (arg: Animal) => Animal;
+getRootTag: (arg: RootTag) => RootTag;
+getValue: (x: number, y: string, z: Object) => Object;
+getValueWithCallback: (callback: (value: string) => void) => void;
+getValueWithPromise: (error: boolean) => Promise<string>;
readonly voidFunc: () => void;
readonly getBool: (arg: boolean) => boolean;
readonly getNumber: (arg: number) => number;
readonly getString: (arg: string) => string;
readonly getArray: (arg: Array<any>) => Array<any>;
readonly getObject: (arg: Object) => Object;
readonly getObjectShape: (arg: {prop: number}) => {prop: number};
readonly getAlias: (arg: Animal) => Animal;
readonly getRootTag: (arg: RootTag) => RootTag;
readonly getValue: (x: number, y: string, z: Object) => Object;
readonly getValueWithCallback: (callback: (value: string) => void) => void;
readonly getValueWithPromise: (error: boolean) => Promise<string>;
}
export default TurboModuleRegistry.getEnforcing<Spec>(
@@ -21,28 +21,34 @@ type Animal = {
export interface Spec extends TurboModule {
// Exported methods.
+getConstants: () => {
readonly getConstants: () => {
const1: Array<boolean>,
const2: Array<number>,
const3: Array<string>,
id?: Array<?{prop: number}>,
};
+voidFunc: () => void;
+getBool: (id: Array<boolean>) => Array<boolean>;
+getNumber: (arg: Array<number>) => Array<number>;
+getString: (arg: Array<string>) => Array<string>;
+getArray: (arg: Array<Array<any>>) => Array<Array<any>>;
+getObject: (arg: Array<Object>) => Array<Object>;
+getObjectShape: (arg: Array<{prop: number}>) => Array<{prop: number}>;
+getAlias: (arg: Array<Animal>) => Array<Animal>;
+getRootTag: (arg: Array<RootTag>) => Array<RootTag>;
+getValue: (
readonly voidFunc: () => void;
readonly getBool: (id: Array<boolean>) => Array<boolean>;
readonly getNumber: (arg: Array<number>) => Array<number>;
readonly getString: (arg: Array<string>) => Array<string>;
readonly getArray: (arg: Array<Array<any>>) => Array<Array<any>>;
readonly getObject: (arg: Array<Object>) => Array<Object>;
readonly getObjectShape: (
arg: Array<{prop: number}>,
) => Array<{prop: number}>;
readonly getAlias: (arg: Array<Animal>) => Array<Animal>;
readonly getRootTag: (arg: Array<RootTag>) => Array<RootTag>;
readonly getValue: (
x: Array<number>,
y: Array<string>,
z: Array<Object>,
) => Array<Object>;
+getValueWithCallback: (callback: (value: Array<string>) => void) => void;
+getValueWithPromise: (error: Array<boolean>) => Promise<Array<string>>;
readonly getValueWithCallback: (
callback: (value: Array<string>) => void,
) => void;
readonly getValueWithPromise: (
error: Array<boolean>,
) => Promise<Array<string>>;
}
export default TurboModuleRegistry.getEnforcing<Spec>(
@@ -21,23 +21,23 @@ type Animal = ?{
export interface Spec extends TurboModule {
// Exported methods.
+getConstants: () => {
readonly getConstants: () => {
const1: ?boolean,
const2: ?number,
const3: ?string,
};
+voidFunc: () => void;
+getBool: (arg: ?boolean) => ?boolean;
+getNumber: (arg: ?number) => ?number;
+getString: (arg: ?string) => ?string;
+getArray: (arg: ?Array<any>) => ?Array<any>;
+getObject: (arg: ?Object) => ?Object;
+getObjectShape: (arg: ?{prop: ?number}) => ?{prop: ?number};
+getAlias: (arg: ?Animal) => ?Animal;
+getRootTag: (arg: ?RootTag) => ?RootTag;
+getValue: (x: ?number, y: ?string, z: ?Object) => ?Object;
+getValueWithCallback: (callback: (value: ?string) => void) => void;
+getValueWithPromise: (error: ?boolean) => ?Promise<string>;
readonly voidFunc: () => void;
readonly getBool: (arg: ?boolean) => ?boolean;
readonly getNumber: (arg: ?number) => ?number;
readonly getString: (arg: ?string) => ?string;
readonly getArray: (arg: ?Array<any>) => ?Array<any>;
readonly getObject: (arg: ?Object) => ?Object;
readonly getObjectShape: (arg: ?{prop: ?number}) => ?{prop: ?number};
readonly getAlias: (arg: ?Animal) => ?Animal;
readonly getRootTag: (arg: ?RootTag) => ?RootTag;
readonly getValue: (x: ?number, y: ?string, z: ?Object) => ?Object;
readonly getValueWithCallback: (callback: (value: ?string) => void) => void;
readonly getValueWithPromise: (error: ?boolean) => ?Promise<string>;
}
export default TurboModuleRegistry.getEnforcing<Spec>(
@@ -21,23 +21,25 @@ type Animal = ?{
export interface Spec extends TurboModule {
// Exported methods.
+getConstants?: () => {
readonly getConstants?: () => {
const1?: ?boolean,
const2?: ?number,
const3?: ?string,
};
+voidFunc?: () => void;
+getBool?: (arg?: ?boolean) => ?boolean;
+getNumber?: (arg?: ?number) => ?number;
+getString?: (arg?: ?string) => ?string;
+getArray?: (arg?: ?Array<any>) => ?Array<any>;
+getObject?: (arg?: ?Object) => ?Object;
+getObjectShape?: (arg?: {prop?: ?number}) => {prop?: ?number};
+getAlias?: (arg?: ?Animal) => ?Animal;
+getRootTag?: (arg?: ?RootTag) => ?RootTag;
+getValue?: (x?: ?number, y?: ?string, z?: ?Object) => ?Object;
+getValueWithCallback?: (callback?: ?(value?: ?string) => void) => void;
+getValueWithPromise?: (error?: ?boolean) => ?Promise<string>;
readonly voidFunc?: () => void;
readonly getBool?: (arg?: ?boolean) => ?boolean;
readonly getNumber?: (arg?: ?number) => ?number;
readonly getString?: (arg?: ?string) => ?string;
readonly getArray?: (arg?: ?Array<any>) => ?Array<any>;
readonly getObject?: (arg?: ?Object) => ?Object;
readonly getObjectShape?: (arg?: {prop?: ?number}) => {prop?: ?number};
readonly getAlias?: (arg?: ?Animal) => ?Animal;
readonly getRootTag?: (arg?: ?RootTag) => ?RootTag;
readonly getValue?: (x?: ?number, y?: ?string, z?: ?Object) => ?Object;
readonly getValueWithCallback?: (
callback?: ?(value?: ?string) => void,
) => void;
readonly getValueWithPromise?: (error?: ?boolean) => ?Promise<string>;
}
export default TurboModuleRegistry.getEnforcing<Spec>(
@@ -21,23 +21,23 @@ type Animal = {
export interface Spec extends TurboModule {
// Exported methods.
+getConstants?: () => {
readonly getConstants?: () => {
const1?: boolean,
const2?: number,
const3?: string,
};
+voidFunc?: () => void;
+getBool?: (arg?: boolean) => boolean;
+getNumber?: (arg?: number) => number;
+getString?: (arg?: string) => string;
+getArray?: (arg?: Array<any>) => Array<any>;
+getObject?: (arg?: Object) => Object;
+getObjectShape?: (arg?: {prop?: number}) => {prop?: number};
+getAlias?: (arg?: Animal) => Animal;
+getRootTag?: (arg?: RootTag) => RootTag;
+getValue?: (x?: number, y?: string, z?: Object) => Object;
+getValueWithCallback?: (callback?: (value?: string) => void) => void;
+getValueWithPromise?: (error?: boolean) => Promise<string>;
readonly voidFunc?: () => void;
readonly getBool?: (arg?: boolean) => boolean;
readonly getNumber?: (arg?: number) => number;
readonly getString?: (arg?: string) => string;
readonly getArray?: (arg?: Array<any>) => Array<any>;
readonly getObject?: (arg?: Object) => Object;
readonly getObjectShape?: (arg?: {prop?: number}) => {prop?: number};
readonly getAlias?: (arg?: Animal) => Animal;
readonly getRootTag?: (arg?: RootTag) => RootTag;
readonly getValue?: (x?: number, y?: string, z?: Object) => Object;
readonly getValueWithCallback?: (callback?: (value?: string) => void) => void;
readonly getValueWithPromise?: (error?: boolean) => Promise<string>;
}
export default TurboModuleRegistry.getEnforcing<Spec>(
@@ -16,8 +16,8 @@ export type String = string;
type AnotherString = String;
export interface Spec extends TurboModule {
+getString: (arg: string) => string;
+getStringWithAlias: (arg: String) => AnotherString;
readonly getString: (arg: string) => string;
readonly getStringWithAlias: (arg: String) => AnotherString;
}
export default TurboModuleRegistry.getEnforcing<Spec>(
+8 -8
View File
@@ -72,14 +72,14 @@ export type ArrayBufferTypeAnnotation = Readonly<{
type: 'ArrayBufferTypeAnnotation',
}>;
export type ObjectTypeAnnotation<+T> = Readonly<{
export type ObjectTypeAnnotation<out T> = Readonly<{
type: 'ObjectTypeAnnotation',
properties: ReadonlyArray<NamedShape<T>>,
// metadata for objects that generated from interfaces
baseTypes?: ReadonlyArray<string>,
}>;
export type UnionTypeAnnotation<+T> = Readonly<{
export type UnionTypeAnnotation<out T> = Readonly<{
type: 'UnionTypeAnnotation',
types: ReadonlyArray<T>,
}>;
@@ -93,13 +93,13 @@ export type EventEmitterTypeAnnotation = Readonly<{
typeAnnotation: NativeModuleEventEmitterTypeAnnotation | $FlowFixMe,
}>;
type FunctionTypeAnnotation<+P, +R> = Readonly<{
type FunctionTypeAnnotation<out P, out R> = Readonly<{
type: 'FunctionTypeAnnotation',
params: ReadonlyArray<NamedShape<P>>,
returnTypeAnnotation: R,
}>;
export type NamedShape<+T> = Readonly<{
export type NamedShape<out T> = Readonly<{
name: string,
optional: boolean,
typeAnnotation: T,
@@ -195,7 +195,7 @@ export type ComponentCommandArrayTypeAnnotation = ArrayTypeAnnotation<
| MixedTypeAnnotation,
>;
export type ArrayTypeAnnotation<+T> = Readonly<{
export type ArrayTypeAnnotation<out T> = Readonly<{
type: 'ArrayTypeAnnotation',
elementType: T,
}>;
@@ -269,11 +269,11 @@ export type ReservedTypeAnnotation = Readonly<{
/**
* NativeModule Types
*/
export type Nullable<+T extends NativeModuleTypeAnnotation> =
export type Nullable<out T extends NativeModuleTypeAnnotation> =
| NullableTypeAnnotation<T>
| T;
export type NullableTypeAnnotation<+T extends NativeModuleTypeAnnotation> =
export type NullableTypeAnnotation<out T extends NativeModuleTypeAnnotation> =
Readonly<{
type: 'NullableTypeAnnotation',
typeAnnotation: T,
@@ -321,7 +321,7 @@ export type NativeModuleObjectTypeAnnotation = ObjectTypeAnnotation<
>;
export type NativeModuleArrayTypeAnnotation<
+T extends Nullable<NativeModuleBaseTypeAnnotation>,
out T extends Nullable<NativeModuleBaseTypeAnnotation>,
> = ArrayTypeAnnotation<
| T
/**
@@ -28,99 +28,104 @@ export type ReservedPrimitiveName =
| 'DimensionPrimitive';
type CppTypeInfo = {
+typeName: string,
+localIncludes: ReadonlyArray<string>,
+conversionIncludes: ReadonlyArray<string>,
readonly typeName: string,
readonly localIncludes: ReadonlyArray<string>,
readonly conversionIncludes: ReadonlyArray<string>,
};
type JavaImportInfo = {
+interfaceImports: ReadonlyArray<string>,
+delegateImports: ReadonlyArray<string>,
readonly interfaceImports: ReadonlyArray<string>,
readonly delegateImports: ReadonlyArray<string>,
};
type ReservedTypeMapping = {
+cpp: CppTypeInfo,
+java: JavaImportInfo,
readonly cpp: CppTypeInfo,
readonly java: JavaImportInfo,
};
const RESERVED_TYPES: {+[ReservedPrimitiveName]: ReservedTypeMapping} = {
ColorPrimitive: {
cpp: {
typeName: 'SharedColor',
localIncludes: ['#include <react/renderer/graphics/Color.h>'],
conversionIncludes: [],
const RESERVED_TYPES: {readonly [ReservedPrimitiveName]: ReservedTypeMapping} =
{
ColorPrimitive: {
cpp: {
typeName: 'SharedColor',
localIncludes: ['#include <react/renderer/graphics/Color.h>'],
conversionIncludes: [],
},
java: {
interfaceImports: [],
delegateImports: [
'import com.facebook.react.bridge.ColorPropConverter;',
],
},
},
java: {
interfaceImports: [],
delegateImports: ['import com.facebook.react.bridge.ColorPropConverter;'],
ImageSourcePrimitive: {
cpp: {
typeName: 'ImageSource',
localIncludes: ['#include <react/renderer/imagemanager/primitives.h>'],
conversionIncludes: [
'#include <react/renderer/components/image/conversions.h>',
],
},
java: {
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
},
},
},
ImageSourcePrimitive: {
cpp: {
typeName: 'ImageSource',
localIncludes: ['#include <react/renderer/imagemanager/primitives.h>'],
conversionIncludes: [
'#include <react/renderer/components/image/conversions.h>',
],
ImageRequestPrimitive: {
cpp: {
typeName: 'ImageRequest',
localIncludes: [
'#include <react/renderer/imagemanager/ImageRequest.h>',
],
conversionIncludes: [],
},
java: {
// ImageRequestPrimitive is not used in Java component props
interfaceImports: [],
delegateImports: [],
},
},
java: {
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
PointPrimitive: {
cpp: {
typeName: 'Point',
localIncludes: ['#include <react/renderer/graphics/Point.h>'],
conversionIncludes: [],
},
java: {
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
},
},
},
ImageRequestPrimitive: {
cpp: {
typeName: 'ImageRequest',
localIncludes: ['#include <react/renderer/imagemanager/ImageRequest.h>'],
conversionIncludes: [],
EdgeInsetsPrimitive: {
cpp: {
typeName: 'EdgeInsets',
localIncludes: ['#include <react/renderer/graphics/RectangleEdges.h>'],
conversionIncludes: [],
},
java: {
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
},
},
java: {
// ImageRequestPrimitive is not used in Java component props
interfaceImports: [],
delegateImports: [],
DimensionPrimitive: {
cpp: {
typeName: 'YGValue',
localIncludes: [
'#include <yoga/Yoga.h>',
'#include <react/renderer/core/graphicsConversions.h>',
],
conversionIncludes: [
'#include <react/renderer/components/view/conversions.h>',
],
},
java: {
interfaceImports: ['import com.facebook.yoga.YogaValue;'],
delegateImports: [
'import com.facebook.react.bridge.DimensionPropConverter;',
],
},
},
},
PointPrimitive: {
cpp: {
typeName: 'Point',
localIncludes: ['#include <react/renderer/graphics/Point.h>'],
conversionIncludes: [],
},
java: {
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
},
},
EdgeInsetsPrimitive: {
cpp: {
typeName: 'EdgeInsets',
localIncludes: ['#include <react/renderer/graphics/RectangleEdges.h>'],
conversionIncludes: [],
},
java: {
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
},
},
DimensionPrimitive: {
cpp: {
typeName: 'YGValue',
localIncludes: [
'#include <yoga/Yoga.h>',
'#include <react/renderer/core/graphicsConversions.h>',
],
conversionIncludes: [
'#include <react/renderer/components/view/conversions.h>',
],
},
java: {
interfaceImports: ['import com.facebook.yoga.YogaValue;'],
delegateImports: [
'import com.facebook.react.bridge.DimensionPropConverter;',
],
},
},
};
};
function getCppTypeForReservedPrimitive(name: ReservedPrimitiveName): string {
return RESERVED_TYPES[name].cpp.typeName;
@@ -49,13 +49,13 @@ function getNativeTypeFromAnnotation(
| ObjectTypeAnnotation<PropTypeAnnotation>
| ReservedPropTypeAnnotation
| {
+default: string,
+options: ReadonlyArray<string>,
+type: 'StringEnumTypeAnnotation',
readonly default: string,
readonly options: ReadonlyArray<string>,
readonly type: 'StringEnumTypeAnnotation',
}
| {
+elementType: ObjectTypeAnnotation<PropTypeAnnotation>,
+type: 'ArrayTypeAnnotation',
readonly elementType: ObjectTypeAnnotation<PropTypeAnnotation>,
readonly type: 'ArrayTypeAnnotation',
},
},
nameParts: ReadonlyArray<string>,
+1 -1
View File
@@ -128,7 +128,7 @@ class UnsupportedModulePropertyParserError extends ParserError {
}
class UnsupportedTypeAnnotationParserError extends ParserError {
+typeAnnotationType: string;
readonly typeAnnotationType: string;
constructor(
nativeModuleName: string,
typeAnnotation: $FlowFixMe,
@@ -17,7 +17,7 @@ const {verifyPropNotAlreadyDefined} = require('../../parsers-commons');
const {getValueFromTypes} = require('../utils.js');
// $FlowFixMe[unsupported-variance-annotation]
function getTypeAnnotationForArray<+T>(
function getTypeAnnotationForArray<out T>(
name: string,
typeAnnotation: $FlowFixMe,
defaultValue: $FlowFixMe | null,
@@ -219,7 +219,7 @@ function flattenProperties(
}
// $FlowFixMe[unsupported-variance-annotation]
function getTypeAnnotation<+T>(
function getTypeAnnotation<out T>(
name: string,
annotation: $FlowFixMe | ASTNode,
defaultValue: $FlowFixMe | null,
@@ -107,7 +107,7 @@ function wrapModuleSchema(
}
// $FlowFixMe[unsupported-variance-annotation]
function unwrapNullable<+T extends NativeModuleTypeAnnotation>(
function unwrapNullable<out T extends NativeModuleTypeAnnotation>(
x: Nullable<T>,
): [T, boolean] {
if (x.type === 'NullableTypeAnnotation') {
@@ -118,7 +118,7 @@ function unwrapNullable<+T extends NativeModuleTypeAnnotation>(
}
// $FlowFixMe[unsupported-variance-annotation]
function wrapNullable<+T extends NativeModuleTypeAnnotation>(
function wrapNullable<out T extends NativeModuleTypeAnnotation>(
nullable: boolean,
typeAnnotation: T,
): Nullable<T> {
@@ -91,53 +91,83 @@ type CustomObj = {foo: string, bar: number};
type CustomObj2 = {a: Int32, b: string};
interface NativeCommands {
+methodInt: (viewRef: React.ElementRef<NativeType>, a: Int32) => void;
+methodIntString: (
readonly methodInt: (viewRef: React.ElementRef<NativeType>, a: Int32) => void;
readonly methodIntString: (
viewRef: React.ElementRef<NativeType>,
a: Int32,
b: string,
) => void;
+methodString: (viewRef: React.ElementRef<NativeType>, a: string) => void;
+methodBool: (viewRef: React.ElementRef<NativeType>, a: boolean) => void;
+methodFloat: (viewRef: React.ElementRef<NativeType>, a: Float) => void;
+methodDouble: (viewRef: React.ElementRef<NativeType>, a: Double) => void;
readonly methodString: (
viewRef: React.ElementRef<NativeType>,
a: string,
) => void;
readonly methodBool: (
viewRef: React.ElementRef<NativeType>,
a: boolean,
) => void;
readonly methodFloat: (
viewRef: React.ElementRef<NativeType>,
a: Float,
) => void;
readonly methodDouble: (
viewRef: React.ElementRef<NativeType>,
a: Double,
) => void;
+methodIntAlias: (viewRef: React.ElementRef<NativeType>, a: Int) => void;
+methodStringAlias: (viewRef: React.ElementRef<NativeType>, a: Str) => void;
+methodBoolAlias: (viewRef: React.ElementRef<NativeType>, a: Bool) => void;
+methodFloatAlias: (viewRef: React.ElementRef<NativeType>, a: Fl) => void;
+methodDoubleAlias: (viewRef: React.ElementRef<NativeType>, a: Dbl) => void;
readonly methodIntAlias: (
viewRef: React.ElementRef<NativeType>,
a: Int,
) => void;
readonly methodStringAlias: (
viewRef: React.ElementRef<NativeType>,
a: Str,
) => void;
readonly methodBoolAlias: (
viewRef: React.ElementRef<NativeType>,
a: Bool,
) => void;
readonly methodFloatAlias: (
viewRef: React.ElementRef<NativeType>,
a: Fl,
) => void;
readonly methodDoubleAlias: (
viewRef: React.ElementRef<NativeType>,
a: Dbl,
) => void;
+methodIntArray: (
readonly methodIntArray: (
viewRef: React.ElementRef<NativeType>,
a: Array<Int32>,
) => void;
+methodStringArray: (
readonly methodStringArray: (
viewRef: React.ElementRef<NativeType>,
a: Array<string>,
) => void;
+methodBoolArray: (
readonly methodBoolArray: (
viewRef: React.ElementRef<NativeType>,
a: Array<boolean>,
) => void;
+methodFloatArray: (
readonly methodFloatArray: (
viewRef: React.ElementRef<NativeType>,
a: Array<Float>,
) => void;
+methodDoubleArray: (
readonly methodDoubleArray: (
viewRef: React.ElementRef<NativeType>,
a: Array<Double>,
) => void;
+methodCustomObjArray: (
readonly methodCustomObjArray: (
viewRef: React.ElementRef<NativeType>,
a: Array<CustomObj>,
) => void;
+methodCustomObj2Array: (
readonly methodCustomObj2Array: (
viewRef: React.ElementRef<NativeType>,
a: Array<CustomObj2>,
) => void;
+methodRootTag: (viewRef: React.ElementRef<NativeType>, a: RootTag) => void;
readonly methodRootTag: (
viewRef: React.ElementRef<NativeType>,
a: RootTag,
) => void;
}
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
@@ -26,20 +26,23 @@ type NativeProps = Readonly<{
type NativeType = HostComponent<NativeProps>;
interface NativeCommands {
+methodInt: (viewRef: React.ElementRef<NativeType>, a: Array<Int32>) => void;
+methodString: (
readonly methodInt: (
viewRef: React.ElementRef<NativeType>,
a: Array<Int32>,
) => void;
readonly methodString: (
viewRef: React.ElementRef<NativeType>,
a: Array<string>,
) => void;
+methodBool: (
readonly methodBool: (
viewRef: React.ElementRef<NativeType>,
a: Array<boolean>,
) => void;
+methodFloat: (
readonly methodFloat: (
viewRef: React.ElementRef<NativeType>,
a: Array<Float>,
) => void;
+methodDouble: (
readonly methodDouble: (
viewRef: React.ElementRef<NativeType>,
a: Array<Double>,
) => void;
@@ -26,11 +26,23 @@ type NativeProps = Readonly<{
type NativeType = HostComponent<NativeProps>;
interface NativeCommands {
+methodInt: (viewRef: React.ElementRef<NativeType>, a: Int32) => void;
+methodString: (viewRef: React.ElementRef<NativeType>, a: string) => void;
+methodBool: (viewRef: React.ElementRef<NativeType>, a: boolean) => void;
+methodFloat: (viewRef: React.ElementRef<NativeType>, a: Float) => void;
+methodDouble: (viewRef: React.ElementRef<NativeType>, a: Double) => void;
readonly methodInt: (viewRef: React.ElementRef<NativeType>, a: Int32) => void;
readonly methodString: (
viewRef: React.ElementRef<NativeType>,
a: string,
) => void;
readonly methodBool: (
viewRef: React.ElementRef<NativeType>,
a: boolean,
) => void;
readonly methodFloat: (
viewRef: React.ElementRef<NativeType>,
a: Float,
) => void;
readonly methodDouble: (
viewRef: React.ElementRef<NativeType>,
a: Double,
) => void;
}
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
@@ -21,7 +21,10 @@ type NativeProps = Readonly<{
type NativeType = HostComponent<NativeProps>;
interface NativeCommands {
+methodInt: (viewRef: React.ElementRef<NativeType>, a: string) => void;
readonly methodInt: (
viewRef: React.ElementRef<NativeType>,
a: string,
) => void;
}
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
@@ -22,7 +22,7 @@ type NativeProps = Readonly<{
type NativeType = HostComponent<NativeProps>;
interface NativeCommands {
+methodInt: (
readonly methodInt: (
viewRef: React.ElementRef<NativeType>,
a: Int32,
b: string,
@@ -22,8 +22,11 @@ type NativeProps = Readonly<{
type NativeType = HostComponent<NativeProps>;
interface NativeCommands {
+methodInt: (viewRef: React.ElementRef<NativeType>, a: Int32) => void;
+methodString: (viewRef: React.ElementRef<NativeType>, a: string) => void;
readonly methodInt: (viewRef: React.ElementRef<NativeType>, a: Int32) => void;
readonly methodString: (
viewRef: React.ElementRef<NativeType>,
a: string,
) => void;
}
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
@@ -22,7 +22,7 @@ type NativeProps = Readonly<{
type NativeType = HostComponent<NativeProps>;
interface NativeCommands {
+methodInt: (viewRef: React.ElementRef<NativeType>, a: Int32) => void;
readonly methodInt: (viewRef: React.ElementRef<NativeType>, a: Int32) => void;
}
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
@@ -21,11 +21,11 @@ type BeforeMatchingGeneric<T> = {||};
type AfterMatchingGeneric<T> = {||};
export interface Spec extends TurboModule {
+simpleObject: (a: SimpleObject) => void;
+beforeMismatchGeneric: <T>(a: BeforeMismatchGeneric<T>) => void;
readonly simpleObject: (a: SimpleObject) => void;
readonly beforeMismatchGeneric: <T>(a: BeforeMismatchGeneric<T>) => void;
+beforeMatchingGeneric: <T>(a: BeforeMatchingGeneric<T>) => void;
+afterMatchingGeneric: <T>(a: AfterMatchingGeneric<T>) => void;
readonly beforeMatchingGeneric: <T>(a: BeforeMatchingGeneric<T>) => void;
readonly afterMatchingGeneric: <T>(a: AfterMatchingGeneric<T>) => void;
}
TurboModuleRegistry.getEnforcing<Spec>(
@@ -44,32 +44,32 @@ type SimpleArray = Array<string>;
type SimpleArrayChange = Array<string>;
export interface Spec extends TurboModule {
+exampleFunction: (a: SimpleObject) => void;
+simpleObject: (a: SimpleObject) => void;
+beforeMismatchGeneric: <T>(a: BeforeMismatchGeneric<T>) => void;
+afterMismatchGeneric: <Foo>(a: AfterMismatchGeneric<Foo>) => void;
readonly exampleFunction: (a: SimpleObject) => void;
readonly simpleObject: (a: SimpleObject) => void;
readonly beforeMismatchGeneric: <T>(a: BeforeMismatchGeneric<T>) => void;
readonly afterMismatchGeneric: <Foo>(a: AfterMismatchGeneric<Foo>) => void;
+beforeMatchingGeneric: <T>(a: BeforeMatchingGeneric<T>) => void;
+afterMatchingGeneric: <T>(a: AfterMatchingGeneric<T>) => void;
readonly beforeMatchingGeneric: <T>(a: BeforeMatchingGeneric<T>) => void;
readonly afterMatchingGeneric: <T>(a: AfterMatchingGeneric<T>) => void;
+booleanType: (a: BooleanType) => void;
+stringType: (a: StringType) => void;
readonly booleanType: (a: BooleanType) => void;
readonly stringType: (a: StringType) => void;
+simpleFunction: (a: string) => string;
+simpleFunction2: (a: string) => number;
+simpleFunction3: (foo: string) => string;
+simpleFunction4: (a: number) => string;
readonly simpleFunction: (a: string) => string;
readonly simpleFunction2: (a: string) => number;
readonly simpleFunction3: (foo: string) => string;
readonly simpleFunction4: (a: number) => string;
+simpleUnion: (a: SimpleUnion) => void;
+simpleUnionLonger: (a: SimpleUnionLonger) => void;
+simpleUnionOrderChanged: (a: SimpleUnionOrderChanged) => void;
+simpleUnion2: (a: SimpleUnion2) => void;
+simpleUnion2OrderChanged: (a: SimpleUnion2OrderChanged) => void;
+simpleUnion3: (a: SimpleUnion3) => void;
+simpleUnion4: (a: SimpleUnion4) => void;
readonly simpleUnion: (a: SimpleUnion) => void;
readonly simpleUnionLonger: (a: SimpleUnionLonger) => void;
readonly simpleUnionOrderChanged: (a: SimpleUnionOrderChanged) => void;
readonly simpleUnion2: (a: SimpleUnion2) => void;
readonly simpleUnion2OrderChanged: (a: SimpleUnion2OrderChanged) => void;
readonly simpleUnion3: (a: SimpleUnion3) => void;
readonly simpleUnion4: (a: SimpleUnion4) => void;
+simpleArray: (a: SimpleArray) => void;
+simpleArrayChange: (a: SimpleArrayChange) => void;
readonly simpleArray: (a: SimpleArray) => void;
readonly simpleArrayChange: (a: SimpleArrayChange) => void;
}
TurboModuleRegistry.getEnforcing<Spec>(
@@ -38,33 +38,33 @@ type SimpleArrayChange = Array<number>;
export interface Spec extends TurboModule {
+exampleFunction: (a: SimpleObject) => void;
+simpleObject: (a: SimpleObject) => void;
+beforeMismatchGeneric: <T>(a: BeforeMismatchGeneric<T>) => void;
+afterMismatchGeneric: <Foo>(a: AfterMismatchGeneric<Foo>) => void;
readonly exampleFunction: (a: SimpleObject) => void;
readonly simpleObject: (a: SimpleObject) => void;
readonly beforeMismatchGeneric: <T>(a: BeforeMismatchGeneric<T>) => void;
readonly afterMismatchGeneric: <Foo>(a: AfterMismatchGeneric<Foo>) => void;
+beforeMatchingGeneric: <T>(a: BeforeMatchingGeneric<T>) => void;
+afterMatchingGeneric: <T>(a: AfterMatchingGeneric<T>) => void;
readonly beforeMatchingGeneric: <T>(a: BeforeMatchingGeneric<T>) => void;
readonly afterMatchingGeneric: <T>(a: AfterMatchingGeneric<T>) => void;
+arrayBufferType: (a: ArrayBufferType) => void;
+booleanType: (a: BooleanType) => void;
+stringType: (a: StringType) => void;
readonly arrayBufferType: (a: ArrayBufferType) => void;
readonly booleanType: (a: BooleanType) => void;
readonly stringType: (a: StringType) => void;
+simpleFunction: (a: string) => string;
+simpleFunction2: (a: string) => number;
+simpleFunction3: (foo: string) => string;
+simpleFunction4: (a: number) => string;
readonly simpleFunction: (a: string) => string;
readonly simpleFunction2: (a: string) => number;
readonly simpleFunction3: (foo: string) => string;
readonly simpleFunction4: (a: number) => string;
+simpleUnion: (a: SimpleUnion) => void;
+simpleUnionLonger: (a: SimpleUnionLonger) => void;
+simpleUnionOrderChanged: (a: SimpleUnionOrderChanged) => void;
+simpleUnion2: (a: SimpleUnion2) => void;
+simpleUnion2OrderChanged: (a: SimpleUnion2OrderChanged) => void;
+simpleUnion3: (a: SimpleUnion3) => void;
+simpleUnion4: (a: SimpleUnion4) => void;
readonly simpleUnion: (a: SimpleUnion) => void;
readonly simpleUnionLonger: (a: SimpleUnionLonger) => void;
readonly simpleUnionOrderChanged: (a: SimpleUnionOrderChanged) => void;
readonly simpleUnion2: (a: SimpleUnion2) => void;
readonly simpleUnion2OrderChanged: (a: SimpleUnion2OrderChanged) => void;
readonly simpleUnion3: (a: SimpleUnion3) => void;
readonly simpleUnion4: (a: SimpleUnion4) => void;
+simpleArray: (a: SimpleArray) => void;
+simpleArrayChange: (a: SimpleArrayChange) => void;
readonly simpleArray: (a: SimpleArray) => void;
readonly simpleArrayChange: (a: SimpleArrayChange) => void;
}
TurboModuleRegistry.getEnforcing<Spec>(
@@ -13,9 +13,9 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+exampleFunction: (a: string, b: number) => void;
+getConstants: () => {
+exampleConstant: string,
readonly exampleFunction: (a: string, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: string,
};
}
@@ -13,8 +13,8 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+exampleFunction: (a: string, b: number) => void;
+getConstants: () => Readonly<{
readonly exampleFunction: (a: string, b: number) => void;
readonly getConstants: () => Readonly<{
constant?: string,
}>;
}
@@ -13,9 +13,9 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+exampleFunction: (a: string, b: number) => void;
+getConstants: () => {
+constant?: string,
readonly exampleFunction: (a: string, b: number) => void;
readonly getConstants: () => {
readonly constant?: string,
};
}
@@ -13,8 +13,8 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+exampleFunction: (a: string, b: number) => void;
+getConstants: () => Readonly<{
readonly exampleFunction: (a: string, b: number) => void;
readonly getConstants: () => Readonly<{
constant: string,
}>;
}
@@ -13,9 +13,9 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+exampleFunction: (a: string, b: number) => void;
+getConstants: () => {
+constant: string,
readonly exampleFunction: (a: string, b: number) => void;
readonly getConstants: () => {
readonly constant: string,
};
}
@@ -13,8 +13,8 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+exampleFunction: (a: string, b: number) => void;
+getConstants: () => Readonly<{}>;
readonly exampleFunction: (a: string, b: number) => void;
readonly getConstants: () => Readonly<{}>;
}
export default TurboModuleRegistry.getEnforcing<Spec>(
@@ -13,8 +13,8 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+exampleFunction: (a: string, b: number) => void;
+getConstants: () => {};
readonly exampleFunction: (a: string, b: number) => void;
readonly getConstants: () => {};
}
export default TurboModuleRegistry.getEnforcing<Spec>(
@@ -15,7 +15,7 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo
type MyType = () => Promise<number>;
export interface Spec extends TurboModule {
+exampleFunction: (a: MyType, b: number) => void;
readonly exampleFunction: (a: MyType, b: number) => void;
}
export default TurboModuleRegistry.getEnforcing<Spec>(
@@ -15,7 +15,7 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo
type MyType = () => Promise<string>;
export interface Spec extends TurboModule {
+exampleFunction: (a: MyType, b: number) => void;
readonly exampleFunction: (a: MyType, b: number) => void;
}
export default TurboModuleRegistry.getEnforcing<Spec>(
@@ -13,7 +13,7 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+exampleFunction: (
readonly exampleFunction: (
a: {
a1: string,
a2: number,
@@ -22,8 +22,8 @@ export interface Spec extends TurboModule {
},
b: number,
) => void;
+getConstants: () => {
+exampleConstant: string,
readonly getConstants: () => {
readonly exampleConstant: string,
};
}
@@ -13,7 +13,7 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+exampleFunction: (
readonly exampleFunction: (
a: ?{
a1: string,
a2?: number,
@@ -22,8 +22,8 @@ export interface Spec extends TurboModule {
},
b: number,
) => void;
+getConstants: () => {
+exampleConstant: string,
readonly getConstants: () => {
readonly exampleConstant: string,
};
}
@@ -13,7 +13,7 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+exampleFunction: (
readonly exampleFunction: (
a: {
a1: string,
a2?: number,
@@ -22,8 +22,8 @@ export interface Spec extends TurboModule {
},
b: number,
) => void;
+getConstants: () => {
+exampleConstant: string,
readonly getConstants: () => {
readonly exampleConstant: string,
};
}
@@ -13,7 +13,7 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+exampleFunction: (
readonly exampleFunction: (
a: {
a1: string,
a2: number,
@@ -21,8 +21,8 @@ export interface Spec extends TurboModule {
},
b: number,
) => void;
+getConstants: () => {
+exampleConstant: string,
readonly getConstants: () => {
readonly exampleConstant: string,
};
}
@@ -170,53 +170,53 @@ enum EnumUnsorted {
}
export interface Spec extends TurboModule {
+stringLiteral0: (a: StringLiteral0) => void;
+stringLiteral1: (a: StringLiteral1) => void;
readonly stringLiteral0: (a: StringLiteral0) => void;
readonly stringLiteral1: (a: StringLiteral1) => void;
+booleanLiteral0: (a: BooleanLiteral0) => void;
+booleanLiteral1: (a: BooleanLiteral1) => void;
readonly booleanLiteral0: (a: BooleanLiteral0) => void;
readonly booleanLiteral1: (a: BooleanLiteral1) => void;
+numericLiteral0: (a: NumericLiteral0) => void;
+numericLiteral1: (a: NumericLiteral1) => void;
readonly numericLiteral0: (a: NumericLiteral0) => void;
readonly numericLiteral1: (a: NumericLiteral1) => void;
+stringLiteralUnion0: (a: StringLiteralUnion0) => void;
+stringLiteralUnion1: (a: StringLiteralUnion1) => void;
+stringLiteralUnion2: (a: StringLiteralUnion2) => void;
readonly stringLiteralUnion0: (a: StringLiteralUnion0) => void;
readonly stringLiteralUnion1: (a: StringLiteralUnion1) => void;
readonly stringLiteralUnion2: (a: StringLiteralUnion2) => void;
+referenceType: (a: ReferenceType) => void;
+referenceType2: (a: ReferenceType2) => void;
+referenceType3: (a: ReferenceType3) => void;
readonly referenceType: (a: ReferenceType) => void;
readonly referenceType2: (a: ReferenceType2) => void;
readonly referenceType3: (a: ReferenceType3) => void;
+referenceGeneric: <T>(a: ReferenceGeneric<T>) => void;
+referenceGeneric2: <T, X>(a: ReferenceGeneric2<T, X>) => void;
readonly referenceGeneric: <T>(a: ReferenceGeneric<T>) => void;
readonly referenceGeneric2: <T, X>(a: ReferenceGeneric2<T, X>) => void;
+objectTypeWithProps: (a: ObjectTypeWithProps) => void;
+objectTypeLessProps: (a: ObjectTypeLessProps) => void;
+objectTypeWithDifferentProps: (a: ObjectTypeWithDifferentProps) => void;
+objectTypeWithNesting: (a: ObjectTypeWithNesting) => void;
+objectTypeWithChanges: (a: ObjectTypeWithChanges) => void;
+objectTypeWithNestedChanges: (a: ObjectTypeWithNestedChanges) => void;
+objectTypeWithTwoOptionals: (a: ObjectTypeWithTwoOptionals) => void;
+objectTypeWithOptionalNestedChange: (a: ObjectTypeWithOptionalNestedChange) => void;
+nonNullableType: (a: NonNullableType) => void;
+nullableType: (a: NullableType) => void;
+genericObjectType: (a: GenericObjectType) => void;
+unsafeObjectType: (a: UnsafeObjectType) => void;
+optionalTypeLessProps: (a: OptionalTypeLessProps) => void;
+objectTypeLiteral1: (a: ObjectTypeLiteral1) => void;
+objectTypeLiteral2: (a: ObjectTypeLiteral2) => void;
+objectTypeLiteral1TypeAlias: (a: ObjectTypeLiteral1TypeAlias) => void;
+objectTypeLiteral2TypeAlias: (a: ObjectTypeLiteral2TypeAlias) => void;
+genericObjectType: (a: Object) => void;
readonly objectTypeWithProps: (a: ObjectTypeWithProps) => void;
readonly objectTypeLessProps: (a: ObjectTypeLessProps) => void;
readonly objectTypeWithDifferentProps: (a: ObjectTypeWithDifferentProps) => void;
readonly objectTypeWithNesting: (a: ObjectTypeWithNesting) => void;
readonly objectTypeWithChanges: (a: ObjectTypeWithChanges) => void;
readonly objectTypeWithNestedChanges: (a: ObjectTypeWithNestedChanges) => void;
readonly objectTypeWithTwoOptionals: (a: ObjectTypeWithTwoOptionals) => void;
readonly objectTypeWithOptionalNestedChange: (a: ObjectTypeWithOptionalNestedChange) => void;
readonly nonNullableType: (a: NonNullableType) => void;
readonly nullableType: (a: NullableType) => void;
readonly genericObjectType: (a: GenericObjectType) => void;
readonly unsafeObjectType: (a: UnsafeObjectType) => void;
readonly optionalTypeLessProps: (a: OptionalTypeLessProps) => void;
readonly objectTypeLiteral1: (a: ObjectTypeLiteral1) => void;
readonly objectTypeLiteral2: (a: ObjectTypeLiteral2) => void;
readonly objectTypeLiteral1TypeAlias: (a: ObjectTypeLiteral1TypeAlias) => void;
readonly objectTypeLiteral2TypeAlias: (a: ObjectTypeLiteral2TypeAlias) => void;
readonly genericObjectType: (a: Object) => void;
+mapWithKey: (a: MapWithKey) => void;
+mapWithKey2: (a: MapWithKey2) => void;
readonly mapWithKey: (a: MapWithKey) => void;
readonly mapWithKey2: (a: MapWithKey2) => void;
+enum: (a: Enum) => void;
+enumWithTypeChange: (a: EnumWithTypeChange) => void;
+enumWithRemoval: (a: EnumWithRemoval) => void;
+enumWithValueChange: (a: EnumWithValueChange) => void;
+enumUnsorted: (a: EnumUnsorted) => void;
readonly enum: (a: Enum) => void;
readonly enumWithTypeChange: (a: EnumWithTypeChange) => void;
readonly enumWithRemoval: (a: EnumWithRemoval) => void;
readonly enumWithValueChange: (a: EnumWithValueChange) => void;
readonly enumUnsorted: (a: EnumUnsorted) => void;
}
TurboModuleRegistry.getEnforcing<Spec>(
@@ -13,9 +13,9 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+exampleFunction: (a: {[key: string]: string}, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: {[key: string]: string}, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -13,9 +13,9 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+exampleFunction: (a: {[key: string]: number}, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: {[key: string]: number}, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -20,9 +20,9 @@ enum TestEnum {
}
export interface Spec extends TurboModule {
+exampleFunction: (a: TestEnum, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: TestEnum, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -20,9 +20,9 @@ enum TestEnum {
}
export interface Spec extends TurboModule {
+exampleFunction: (a: string, b: number) => void;
+getConstants: () => {
+exampleConstant: TestEnum,
readonly exampleFunction: (a: string, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: TestEnum,
};
}
@@ -19,9 +19,9 @@ enum TestEnum {
}
export interface Spec extends TurboModule {
+exampleFunction: (a: string, b: number) => void;
+getConstants: () => {
+exampleConstant: TestEnum,
readonly exampleFunction: (a: string, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: TestEnum,
};
}
@@ -19,9 +19,9 @@ enum TestEnum {
}
export interface Spec extends TurboModule {
+exampleFunction: (a: string, b: number) => void;
+getConstants: () => {
+exampleConstant: TestEnum,
readonly exampleFunction: (a: string, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: TestEnum,
};
}
@@ -19,9 +19,9 @@ enum TestEnum {
}
export interface Spec extends TurboModule {
+exampleFunction: (a: string, b: number) => void;
+getConstants: () => {
+exampleConstant: TestEnum,
readonly exampleFunction: (a: string, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: TestEnum,
};
}
@@ -20,9 +20,9 @@ enum TestEnum {
}
export interface Spec extends TurboModule {
+exampleFunction: (a: TestEnum, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: TestEnum, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -19,9 +19,9 @@ enum TestEnum {
}
export interface Spec extends TurboModule {
+exampleFunction: (a: TestEnum, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: TestEnum, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -19,9 +19,9 @@ enum TestEnum {
}
export interface Spec extends TurboModule {
+exampleFunction: (a: TestEnum, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: TestEnum, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -13,9 +13,9 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+exampleFunction: (a: string, b: number, c?: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: string, b: number, c?: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -16,9 +16,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo
type BooleanUnion = true | false;
export interface Spec extends TurboModule {
+exampleFunction: (a: BooleanUnion, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: BooleanUnion, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo
type BooleanUnion = true;
export interface Spec extends TurboModule {
+exampleFunction: (a: BooleanUnion, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: BooleanUnion, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo
type testUnion = 'a' | 'b' | 'c' | 'd';
export interface Spec extends TurboModule {
+exampleFunction: (a: testUnion, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: testUnion, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo
type testUnion = 'a' | '0' | '1' | 'a long string';
export interface Spec extends TurboModule {
+exampleFunction: (a: testUnion, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: testUnion, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo
type testUnion = 'a' | 'b' | 'c' | 'd';
export interface Spec extends TurboModule {
+exampleFunction: (a: string, b: number) => void;
+getConstants: () => {
+exampleConstant: testUnion,
readonly exampleFunction: (a: string, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: testUnion,
};
}
@@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo
type testUnion = 'a' | 'b' | 'c';
export interface Spec extends TurboModule {
+exampleFunction: (a: string, b: number) => void;
+getConstants: () => {
+exampleConstant: testUnion,
readonly exampleFunction: (a: string, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: testUnion,
};
}
@@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo
type NumberUnion = 4 | 5 | 6;
export interface Spec extends TurboModule {
+exampleFunction: (a: NumberUnion, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: NumberUnion, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo
type NumberUnion = 1 | 2 | 3;
export interface Spec extends TurboModule {
+exampleFunction: (a: NumberUnion, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: NumberUnion, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -30,9 +30,9 @@ type ObjectC = {|
type ObjectUnion = ObjectA | ObjectB | ObjectC;
export interface Spec extends TurboModule {
+exampleFunction: (a: ObjectUnion, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: ObjectUnion, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -26,9 +26,9 @@ type ObjectB = {|
type ObjectUnion = ObjectA | ObjectB;
export interface Spec extends TurboModule {
+exampleFunction: (a: ObjectUnion, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: ObjectUnion, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -25,9 +25,9 @@ type ObjectB = {|
type ObjectUnion = ObjectA | ObjectB;
export interface Spec extends TurboModule {
+exampleFunction: (a: ObjectUnion, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: ObjectUnion, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo
type testUnion = 1 | 2 | 3;
export interface Spec extends TurboModule {
+exampleFunction: (a: testUnion, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: testUnion, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo
type testUnion = 'a' | 'b' | 'c';
export interface Spec extends TurboModule {
+exampleFunction: (a: testUnion, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: testUnion, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -13,9 +13,9 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+exampleFunction: (a: string, b: number) => void;
+getConstants: () => {
+exampleConstant: number,
readonly exampleFunction: (a: string, b: number) => void;
readonly getConstants: () => {
readonly exampleConstant: number,
};
}
@@ -28,7 +28,7 @@ type PopupMenuSelectionEvent = NativeSyntheticEvent<
type PopupMenuDismissEvent = NativeSyntheticEvent<Readonly<{}>>;
export type PopupMenuAndroidInstance = {
+show: () => void,
readonly show: () => void,
};
type Props = {
@@ -37,7 +37,7 @@ const styles = StyleSheet.create({
});
export type PopupMenuAndroidInstance = {
+show: () => void,
readonly show: () => void,
};
type Props = {
@@ -38,7 +38,7 @@ type NativeProps = Readonly<{
type ComponentType = HostComponent<NativeProps>;
interface NativeCommands {
+show: (viewRef: React.ElementRef<ComponentType>) => void;
readonly show: (viewRef: React.ElementRef<ComponentType>) => void;
}
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
@@ -31,7 +31,7 @@ type Nullable = void | null;
type Primitive = string | number | boolean | symbol | void;
type Builtin = (...ReadonlyArray<empty>) => unknown | Date | Error | RegExp;
export type WithAnimatedValue<+T> = T extends Builtin | Nullable
export type WithAnimatedValue<out T> = T extends Builtin | Nullable
? T
: T extends Primitive
?
@@ -51,7 +51,7 @@ export type WithAnimatedValue<+T> = T extends Builtin | Nullable
: T extends ReadonlyArray<infer P>
? ReadonlyArray<WithAnimatedValue<P>>
: T extends {...}
? {+[K in keyof T]: WithAnimatedValue<T[K]>}
? {readonly [K in keyof T]: WithAnimatedValue<T[K]>}
: T;
type NonAnimatedProps =
@@ -91,7 +91,7 @@ export type AnimatedBaseProps<Props extends {...}> = LooseOmit<
export type AnimatedComponentType<
Props extends {...},
+Instance = unknown,
out Instance = unknown,
> = component(ref?: React.RefSetter<Instance>, ...AnimatedProps<Props>);
export default function createAnimatedComponent<
@@ -30,18 +30,18 @@ export type AnimatedColorConfig = Readonly<{
type ColorListenerCallback = (value: ColorValue) => unknown;
export type RgbaValue = {
+r: number,
+g: number,
+b: number,
+a: number,
readonly r: number,
readonly g: number,
readonly b: number,
readonly a: number,
...
};
type RgbaAnimatedValue = {
+r: AnimatedValue,
+g: AnimatedValue,
+b: AnimatedValue,
+a: AnimatedValue,
readonly r: AnimatedValue,
readonly g: AnimatedValue,
readonly b: AnimatedValue,
readonly a: AnimatedValue,
...
};
@@ -30,7 +30,7 @@ export type AnimatedPropsAllowlist = Readonly<{
}>;
type TargetView = {
+instance: TargetViewInstance,
readonly instance: TargetViewInstance,
connectedViewTag: ?number,
};
type TargetViewInstance = React.ElementRef<React.ElementType>;
@@ -45,8 +45,8 @@ export default class AnimatedValueXY extends AnimatedWithChildren {
constructor(
valueIn?: ?{
+x: number | AnimatedValue,
+y: number | AnimatedValue,
readonly x: number | AnimatedValue,
readonly y: number | AnimatedValue,
...
},
config?: ?AnimatedValueXYConfig,
@@ -10,7 +10,7 @@
declare export class URLSearchParams {
_searchParams: Array<[string, string]>;
+size: number;
readonly size: number;
constructor(
params?: Record<string, string> | string | Array<[string, string]>,
): void;
@@ -135,19 +135,19 @@ export interface ScrollViewScrollToOptions {
// Public methods for ScrollView
export interface ScrollViewImperativeMethods {
+getScrollResponder: () => ScrollResponderType;
+getScrollableNode: () => ?number;
+getInnerViewNode: () => ?number;
+getInnerViewRef: () => InnerViewInstance | null;
+getNativeScrollRef: () => ScrollViewInstance | null;
+scrollTo: (
readonly getScrollResponder: () => ScrollResponderType;
readonly getScrollableNode: () => ?number;
readonly getInnerViewNode: () => ?number;
readonly getInnerViewRef: () => InnerViewInstance | null;
readonly getNativeScrollRef: () => ScrollViewInstance | null;
readonly scrollTo: (
options?: ScrollViewScrollToOptions | number,
deprecatedX?: number,
deprecatedAnimated?: boolean,
) => void;
+scrollToEnd: (options?: ?ScrollViewScrollToOptions) => void;
+flashScrollIndicators: () => void;
+scrollResponderZoomTo: (
readonly scrollToEnd: (options?: ?ScrollViewScrollToOptions) => void;
readonly flashScrollIndicators: () => void;
readonly scrollResponderZoomTo: (
rect: {
x: number,
y: number,
@@ -157,7 +157,7 @@ export interface ScrollViewImperativeMethods {
},
animated?: boolean, // deprecated, put this inside the rect argument instead
) => void;
+scrollResponderScrollNativeHandleToKeyboard: (
readonly scrollResponderScrollNativeHandleToKeyboard: (
nodeHandle: number | HostInstance,
additionalOffset?: number,
preventNegativeScrollOffset?: boolean,
@@ -16,20 +16,20 @@ import * as React from 'react';
type ScrollViewNativeComponentType = HostComponent<{...}>;
interface NativeCommands {
+flashScrollIndicators: (
readonly flashScrollIndicators: (
viewRef: React.ElementRef<ScrollViewNativeComponentType>,
) => void;
+scrollTo: (
readonly scrollTo: (
viewRef: React.ElementRef<ScrollViewNativeComponentType>,
x: Double,
y: Double,
animated: boolean,
) => void;
+scrollToEnd: (
readonly scrollToEnd: (
viewRef: React.ElementRef<ScrollViewNativeComponentType>,
animated: boolean,
) => void;
+zoomToRect: (
readonly zoomToRect: (
viewRef: React.ElementRef<ScrollViewNativeComponentType>,
rect: {
x: Double,
@@ -40,7 +40,7 @@ export type ScrollViewStickyHeaderProps = Readonly<{
}>;
interface Instance extends React.ElementRef<typeof Animated.View> {
+setNextHeaderY: number => void;
readonly setNextHeaderY: number => void;
}
const ScrollViewStickyHeader: component(
@@ -78,7 +78,7 @@ import * as React from 'react';
/** @build-types emit-as-interface Expo compatibility */
export type InputAccessoryViewProps = Readonly<{
+children: React.Node,
readonly children: React.Node,
/**
* An ID which is used to associate this `InputAccessoryView` to
* specified TextInput(s).
@@ -13,9 +13,9 @@ import type {Int32} from '../../Types/CodegenTypes';
import * as React from 'react';
export interface TextInputNativeCommands<T> {
+focus: (viewRef: React.ElementRef<T>) => void;
+blur: (viewRef: React.ElementRef<T>) => void;
+setTextAndSelection: (
readonly focus: (viewRef: React.ElementRef<T>) => void;
readonly blur: (viewRef: React.ElementRef<T>) => void;
readonly setTextAndSelection: (
viewRef: React.ElementRef<T>,
mostRecentEventCount: Int32,
value: ?string, // in theory this is nullable
@@ -25,16 +25,16 @@ import Position from './Position';
import * as React from 'react';
const extractSingleTouch = (nativeEvent: {
+changedTouches: ReadonlyArray<GestureResponderEvent['nativeEvent']>,
+force?: number,
+identifier: number,
+locationX: number,
+locationY: number,
+pageX: number,
+pageY: number,
+target: ?number,
+timestamp: number,
+touches: ReadonlyArray<GestureResponderEvent['nativeEvent']>,
readonly changedTouches: ReadonlyArray<GestureResponderEvent['nativeEvent']>,
readonly force?: number,
readonly identifier: number,
readonly locationX: number,
readonly locationY: number,
readonly pageX: number,
readonly pageY: number,
readonly target: ?number,
readonly timestamp: number,
readonly touches: ReadonlyArray<GestureResponderEvent['nativeEvent']>,
}) => {
const touches = nativeEvent.touches;
const changedTouches = nativeEvent.changedTouches;
@@ -21,10 +21,10 @@ const ViewNativeComponent: HostComponent<Props> =
}));
interface NativeCommands {
+focus: (viewRef: HostInstance) => void;
+blur: (viewRef: HostInstance) => void;
+hotspotUpdate: (viewRef: HostInstance, x: number, y: number) => void;
+setPressed: (viewRef: HostInstance, pressed: boolean) => void;
readonly focus: (viewRef: HostInstance) => void;
readonly blur: (viewRef: HostInstance) => void;
readonly hotspotUpdate: (viewRef: HostInstance, x: number, y: number) => void;
readonly setPressed: (viewRef: HostInstance, pressed: boolean) => void;
}
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
@@ -13,9 +13,9 @@ import type {ExtendedError} from './ExtendedError';
import ExceptionsManager, {SyntheticError} from './ExceptionsManager';
export type CapturedError = {
+componentStack: string,
+error: unknown,
+errorBoundary: ?{...},
readonly componentStack: string,
readonly error: unknown,
readonly errorBoundary: ?{...},
...
};
@@ -11,11 +11,11 @@
'use strict';
export type ResolvedAssetSource = {
+__packager_asset: boolean,
+width: ?number,
+height: ?number,
+uri: string,
+scale: number,
readonly __packager_asset: boolean,
readonly width: ?number,
readonly height: ?number,
readonly uri: string,
readonly scale: number,
};
// From @react-native/assets-registry
+9 -9
View File
@@ -21,32 +21,32 @@ export interface ImageURISource {
* resource (which should be wrapped in the `require('./path/to/image.png')`
* function).
*/
+uri?: ?string;
readonly uri?: ?string;
/**
* `bundle` is the iOS asset bundle which the image is included in. This
* will default to [NSBundle mainBundle] if not set.
* @platform ios
*/
+bundle?: ?string;
readonly bundle?: ?string;
/**
* `method` is the HTTP Method to use. Defaults to GET if not specified.
*/
+method?: ?string;
readonly method?: ?string;
/**
* `headers` is an object representing the HTTP headers to send along with the
* request for a remote image.
*/
+headers?: ?{[string]: string};
readonly headers?: ?{[string]: string};
/**
* `body` is the HTTP body to send with the request. This must be a valid
* UTF-8 string, and will be sent exactly as specified, with no
* additional encoding (e.g. URL-escaping or base64) applied.
*/
+body?: ?string;
readonly body?: ?string;
/**
* `cache` determines how the requests handles potentially cached
@@ -66,20 +66,20 @@ export interface ImageURISource {
* to a URL load request, no attempt is made to load the data from the originating source,
* and the load is considered to have failed.
*/
+cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached');
readonly cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached');
/**
* `width` and `height` can be specified if known at build time, in which case
* these will be used to set the default `<Image/>` component dimensions.
*/
+width?: ?number;
+height?: ?number;
readonly width?: ?number;
readonly height?: ?number;
/**
* `scale` is used to indicate the scale factor of the image. Defaults to 1.0 if
* unspecified, meaning that one image pixel equates to one display point / DIP.
*/
+scale?: ?number;
readonly scale?: ?number;
}
export type ImageRequireSource = number;
+4 -4
View File
@@ -26,10 +26,10 @@ export type ImageSourceHeaders = {
export function getImageSourcesFromImageProps(imageProps: ImageProps):
| ?ResolvedAssetSource
| ReadonlyArray<{
+uri: string,
+headers: ImageSourceHeaders,
+width: ?number,
+height: ?number,
readonly uri: string,
readonly headers: ImageSourceHeaders,
readonly width: ?number,
readonly height: ?number,
...
}> {
let source = resolveAssetSource(imageProps.source);
@@ -45,7 +45,7 @@ type ImageHostComponentProps = Readonly<{
}>;
interface NativeCommands {
+setIsVisible_EXPERIMENTAL: (
readonly setIsVisible_EXPERIMENTAL: (
viewRef: HostInstance,
isVisible: boolean,
time: number,

Some files were not shown because too many files have changed in this diff Show More