Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codegen chokes on imported types #38769

Open
birdofpreyru opened this issue Aug 3, 2023 · 3 comments
Open

Codegen chokes on imported types #38769

birdofpreyru opened this issue Aug 3, 2023 · 3 comments
Assignees
Labels
Needs: React Native Team Attention Never gets stale Prevent those issues and PRs from getting stale Tech: Codegen Related to react-native-codegen Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)

Comments

@birdofpreyru
Copy link
Contributor

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

@birdofpreyru birdofpreyru added Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Aug 3, 2023
@github-actions github-actions bot added the Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. label Aug 3, 2023
@github-actions
Copy link

github-actions bot commented Aug 3, 2023

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.

@cipolleschi
Copy link
Contributor

Yes, that is a currently known limitation of codegen. The (very ugly) workaround is to copy-and-paste the types you need in the module definition.

We are currently working on solving this, so it will be hopefully available soon.

cc. @dmytrorykun

Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Apr 28, 2024
@cortinico cortinico added Never gets stale Prevent those issues and PRs from getting stale and removed Stale There has been a lack of activity on this issue and it may be closed soon. labels Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: React Native Team Attention Never gets stale Prevent those issues and PRs from getting stale Tech: Codegen Related to react-native-codegen Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)
Projects
None yet
Development

No branches or pull requests

4 participants