Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -1062,17 +1062,17 @@ export interface ModuleProps extends ViewProps {
type NativeType = HostComponent<ModuleProps>;

interface NativeCommands {
readonly handleRootTag: (viewRef: React.ElementRef<NativeType>, rootTag: RootTag) => void;
readonly hotspotUpdate: (viewRef: React.ElementRef<NativeType>, x: Int32, y: Int32) => void;
readonly handleRootTag: (viewRef: React.ComponentRef<NativeType>, rootTag: RootTag) => void;
readonly hotspotUpdate: (viewRef: React.ComponentRef<NativeType>, x: Int32, y: Int32) => void;
scrollTo(
viewRef: React.ElementRef<NativeType>,
viewRef: React.ComponentRef<NativeType>,
x: Float,
y: Int32,
z: Double,
animated: boolean,
): void;
readonly arrayArgs: (
viewRef: React.ElementRef<NativeType>,
viewRef: React.ComponentRef<NativeType>,
booleanArray: ReadOnlyArray<boolean>,
stringArray: ReadOnlyArray<string>,
floatArray: ReadOnlyArray<Float>,
Expand Down Expand Up @@ -1122,12 +1122,12 @@ export interface ModuleProps extends ViewProps {
type NativeType = HostComponent<ModuleProps>;

export type ScrollTo = (
viewRef: React.ElementRef<NativeType>,
viewRef: React.ComponentRef<NativeType>,
y: Int,
animated: Boolean,
) => Void;
export type AddOverlays = (
viewRef: React.ElementRef<NativeType>,
viewRef: React.ComponentRef<NativeType>,
overlayColorsReadOnly: ReadOnlyArray<string>,
overlayColorsArray: Array<string>,
overlayColorsArrayAnnotation: string[],
Expand Down Expand Up @@ -1193,7 +1193,7 @@ export interface ModuleNativeState {

type NativeType = HostComponent<ModuleProps>;

export type ScrollTo = (viewRef: React.ElementRef<NativeType>, y: Int, animated: Boolean) => Void;
export type ScrollTo = (viewRef: React.ComponentRef<NativeType>, y: Int, animated: Boolean) => Void;

interface NativeCommands {
readonly scrollTo: ScrollTo;
Expand Down Expand Up @@ -2184,17 +2184,17 @@ export interface ModuleProps extends ViewProps {
type NativeType = HostComponent<ModuleProps>;

interface NativeCommands {
readonly handleRootTag: (viewRef: React.ElementRef<NativeType>, rootTag: RootTag) => void;
readonly hotspotUpdate: (viewRef: React.ElementRef<NativeType>, x: CodegenTypes.Int32, y: CodegenTypes.Int32) => void;
readonly handleRootTag: (viewRef: React.ComponentRef<NativeType>, rootTag: RootTag) => void;
readonly hotspotUpdate: (viewRef: React.ComponentRef<NativeType>, x: CodegenTypes.Int32, y: CodegenTypes.Int32) => void;
scrollTo(
viewRef: React.ElementRef<NativeType>,
viewRef: React.ComponentRef<NativeType>,
x: CodegenTypes.Float,
y: CodegenTypes.Int32,
z: CodegenTypes.Double,
animated: boolean,
): void;
readonly arrayArgs: (
viewRef: React.ElementRef<NativeType>,
viewRef: React.ComponentRef<NativeType>,
booleanArray: ReadOnlyArray<boolean>,
stringArray: ReadOnlyArray<string>,
floatArray: ReadOnlyArray<CodegenTypes.Float>,
Expand Down Expand Up @@ -2243,12 +2243,12 @@ export interface ModuleProps extends ViewProps {
type NativeType = HostComponent<ModuleProps>;

export type ScrollTo = (
viewRef: React.ElementRef<NativeType>,
viewRef: React.ComponentRef<NativeType>,
y: Int,
animated: Boolean,
) => Void;
export type AddOverlays = (
viewRef: React.ElementRef<NativeType>,
viewRef: React.ComponentRef<NativeType>,
overlayColorsReadOnly: ReadOnlyArray<string>,
overlayColorsArray: Array<string>,
overlayColorsArrayAnnotation: string[],
Expand Down Expand Up @@ -2310,7 +2310,7 @@ export interface ModuleNativeState {

type NativeType = HostComponent<ModuleProps>;

export type ScrollTo = (viewRef: React.ElementRef<NativeType>, y: Int, animated: Boolean) => Void;
export type ScrollTo = (viewRef: React.ComponentRef<NativeType>, y: Int, animated: Boolean) => Void;

interface NativeCommands {
readonly scrollTo: ScrollTo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ exports[`RN Codegen TypeScript Parser Fails with error message COMMANDS_DEFINED_

exports[`RN Codegen TypeScript Parser Fails with error message COMMANDS_DEFINED_WITH_MISMATCHED_METHOD_NAMES 1`] = `"codegenNativeCommands expected the same supportedCommands specified in the NativeCommands interface: hotspotUpdate, scrollTo"`;

exports[`RN Codegen TypeScript Parser Fails with error message COMMANDS_DEFINED_WITH_NULLABLE_REF 1`] = `"The first argument of method hotspotUpdate must be of type React.ElementRef<>"`;
exports[`RN Codegen TypeScript Parser Fails with error message COMMANDS_DEFINED_WITH_NULLABLE_REF 1`] = `"The first argument of method hotspotUpdate must be of type React.ElementRef<> or React.ComponentRef<>"`;

exports[`RN Codegen TypeScript Parser Fails with error message COMMANDS_DEFINED_WITHOUT_METHOD_NAMES 1`] = `"codegenNativeCommands must be passed options including the supported commands"`;

exports[`RN Codegen TypeScript Parser Fails with error message COMMANDS_DEFINED_WITHOUT_REF 1`] = `"The first argument of method hotspotUpdate must be of type React.ElementRef<>"`;
exports[`RN Codegen TypeScript Parser Fails with error message COMMANDS_DEFINED_WITHOUT_REF 1`] = `"The first argument of method hotspotUpdate must be of type React.ElementRef<> or React.ComponentRef<>"`;

exports[`RN Codegen TypeScript Parser Fails with error message NON_OPTIONAL_KEY_WITH_DEFAULT_VALUE 1`] = `"key required_key_with_default must be optional if used with WithDefault<> annotation"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ function buildCommandSchemaInternal(
firstParam.typeAnnotation != null &&
firstParam.typeAnnotation.type === 'TSTypeReference' &&
firstParam.typeAnnotation.typeName.left?.name === 'React' &&
firstParam.typeAnnotation.typeName.right?.name === 'ElementRef'
(firstParam.typeAnnotation.typeName.right?.name === 'ElementRef' ||
firstParam.typeAnnotation.typeName.right?.name === 'ComponentRef')
)
) {
throw new Error(
`The first argument of method ${name} must be of type React.ElementRef<>`,
`The first argument of method ${name} must be of type React.ElementRef<> or React.ComponentRef<>`,
);
}

Expand Down
Loading