Skip to content

Codegen chokes on imported types #38769

Open
@birdofpreyru

Description

@birdofpreyru

Description

It seems codegen currently chokes on types imported from a different module, i.e. consider this example:

// types.ts
export type MyType = {
  field: string;
};

// NativeReactNativeMyModule.ts
import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';

import { type MyType } from './types';

export interface Spec extends TurboModule {
  myMethod(arg: MyType): void;
}

export default TurboModuleRegistry.getEnforcing<Spec>('ReactNativeMyModule');

When running the build (for Android on Ubuntu system) the codegen chokes on the method definition saying UnsupportedGenericParserError: Module NativeReactNativeMyModule: Unrecognized generic type 'MyType' in NativeModule spec.

This equivalent code works fine though:

import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';

export type MyType = {
  field: string;
};

export interface Spec extends TurboModule {
  myMethod(arg: MyType): void;
}

export default TurboModuleRegistry.getEnforcing<Spec>('ReactNativeMyModule');

React Native Version

v0.72.3

Output of npx react-native info

N/A

Steps to reproduce

N/A

Snack, code example, screenshot, or link to a repository

N/A

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions