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 complains about unsupported spec type despite of using includesGeneratedCode: true #48621

Open
wjaykim opened this issue Jan 11, 2025 · 3 comments
Labels
Needs: Triage 🔍 Platform: iOS iOS applications. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)

Comments

@wjaykim
Copy link

wjaykim commented Jan 11, 2025

Description

I'm developing Turbo Native Module, which utilizes Event Emitter JS Spec.
The Event Emitter JS Spec was cherry-picked in 0.76.2, so applications using rn version lower than 0.76.2 would break build when they try to build with my library.
So I decided to include generated codes, as documented in codegen documentation, by setting includesGeneratedCode flag to true.
What I expect is as we offers generated code with our library, codegen doesn't need to(and must not) run by application level for our library's JS spec because in the codegen documentation it says:

No need to worry about Codegen version mismatch between what is used by the app, and what was used during library development.

But when I try to build application running on rn lower than 0.76.2 (via running npx @react-native-community/cli codegen) with included generated code, it still complains about the UnsupportedModulePropertyParserError(detailed error log in below).

Am I misunderstanding the includesGeneratedCode option?

Steps to reproduce

  1. Clone https://github.com/wjaykim/rn-codegen-issue-reproducer
  2. Run yarn install
  3. Run npx @react-native-community/cli codegen

React Native Version

0.74.6 - 0.76.1

Affected Platforms

Runtime - iOS, Build - MacOS

Areas

Codegen

Output of npx react-native info

System:
  OS: macOS 15.2
  CPU: (10) arm64 Apple M1 Pro
  Memory: 324.94 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.18.0
    path: ~/.nvm/versions/node/v20.18.0/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v20.18.0/bin/yarn
  npm:
    version: 10.8.2
    path: ~/.nvm/versions/node/v20.18.0/bin/npm
  Watchman:
    version: 2024.12.02.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/user/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2412.12266719
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.13
    path: /usr/bin/javac
  Ruby:
    version: 3.3.5
    path: /Users/user/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.6
    wanted: 0.74.6
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

UnsupportedModulePropertyParserError: Module Native***Module: TypeScript interfaces extending TurboModule must only contain 'FunctionTypeAnnotation's. Property 'on***' refers to a 'TSTypeReference'.
    at throwIfModuleTypeIsUnsupported (/Users/user/test/node_modules/@react-native/codegen/lib/parsers/error-utils.js:163:11)
    at buildPropertySchema (/Users/user/test/node_modules/@react-native/codegen/lib/parsers/parsers-commons.js:472:3)
    at /Users/user/test/node_modules/@react-native/codegen/lib/parsers/parsers-commons.js:705:24
    at guard (/Users/user/test/node_modules/@react-native/codegen/lib/parsers/utils.js:26:14)
    at /Users/user/test/node_modules/@react-native/codegen/lib/parsers/parsers-commons.js:702:14
    at Array.map (<anonymous>)
    at buildModuleSchema (/Users/user/test/node_modules/@react-native/codegen/lib/parsers/parsers-commons.js:699:6)
    at /Users/user/test/node_modules/@react-native/codegen/lib/parsers/parsers-commons.js:522:9
    at guard (/Users/user/test/node_modules/@react-native/codegen/lib/parsers/utils.js:26:14)
    at buildSchemaFromConfigType (/Users/user/test/node_modules/@react-native/codegen/lib/parsers/parsers-commons.js:521:22) {
  nodes: [ undefined ]
}

Reproducer

https://github.com/wjaykim/rn-codegen-issue-reproducer

Screenshots and Videos

No response

@wjaykim wjaykim added Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Jan 11, 2025
@react-native-bot react-native-bot added the Platform: iOS iOS applications. label Jan 11, 2025
@wjaykim wjaykim changed the title iOS Codegen complains about unsupported spec type despite of using includesGeneratedCode: true Codegen complains about unsupported spec type despite of using includesGeneratedCode: true Jan 11, 2025
@princektripathi
Copy link
Collaborator

@wjaykim, my understanding of includesGeneratedCode is also inline with yours. I could see the error while validating your repro.

@dmytrorykun
Copy link
Contributor

@wjaykim Your package.json specifies paths for the generated code, and declares includesGeneratedCode: true, but it looks like there is no generated code at those paths. Could that be the problem?

@wjaykim
Copy link
Author

wjaykim commented Jan 14, 2025

Your package.json specifies paths for the generated code, and declares includesGeneratedCode: true, but it looks like there is no generated code at those paths. Could that be the problem?

@dmytrorykun The generated code is not included in git, but it will be included in npm artifact. Also, as my reproducer installs the package by git, npm/yarn will run prepare script after package install, which triggers codegen script. So there's generated code after the install, actually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Triage 🔍 Platform: iOS iOS applications. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)
Projects
None yet
Development

No branches or pull requests

4 participants