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 fails if there is an interface without extends in NativeLib.ts #34880

Closed
krystofwoldrich opened this issue Oct 6, 2022 · 2 comments
Closed
Labels
Needs: Triage 🔍 p: Sentry Partner: Sentry Partner Stale There has been a lack of activity on this issue and it may be closed soon. Tech: Codegen Related to react-native-codegen Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)

Comments

@krystofwoldrich
Copy link
Contributor

krystofwoldrich commented Oct 6, 2022

Description

Code generation fails when there is an interface without extends in the ts native interface specification.

Expected result would be that this unrelated interface would just be skipped/ignored it should not effect the result in any way.

Version

0.70.1

Output of npx react-native info

System:
OS: macOS 12.6
CPU: (10) x64 Apple M1 Pro
Memory: 42.89 MB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 14.20.1 - ~/.volta/tools/image/node/14.20.1/bin/node
Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
npm: 6.14.17 - ~/.volta/tools/image/node/14.20.1/bin/npm
Watchman: 2022.07.04.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/lib/ruby/gems/2.7.0/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
Android SDK: Not Found
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8815526
Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild
Languages:
Java: 11.0.16 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: >=16.4.1 => 18.2.0
react-native: ^0.70.0 => 0.70.1
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

  1. Create a native interface spec in ts.
import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';

interface UnrelatedToTheSpec {
  name: string;
}

export interface Spec extends TurboModule {
  run(): void;
}

export default TurboModuleRegistry.getEnforcing<Spec>('Lib');
  1. Execute codegen or build of an app that will execute codegen.
 RCT_NEW_ARCH_ENABLED=1 bundle exec pod install

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

Stacktrace:

/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/parsers/typescript/utils.js:114
        throw error;
        ^

TypeError: Cannot read property 'length' of undefined
    at isModuleInterface (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/parsers/typescript/modules/index.js:758:18)
    at Array.filter (<anonymous>)
    at buildModuleSchema (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/parsers/typescript/modules/index.js:773:44)
    at /Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/parsers/typescript/index.js:180:9
    at guard (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/parsers/typescript/utils.js:111:14)
    at buildSchema (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/parsers/typescript/index.js:179:22)
    at Object.parseFile (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/parsers/typescript/index.js:210:10)
    at files.reduce.modules (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/cli/combine/combine-js-to-schema.js:83:30)
    at Array.reduce (<anonymous>)
    at combineSchemas (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/cli/combine/combine-js-to-schema.js:71:16)
Error: Command failed: node /Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/cli/combine/combine-js-to-schema-cli.js /var/folders/tl/jddrmdy97gj0cljrcwb_qkzc0000gn/T/RNSentrySpecrdU0qW/schema.json /Users/krystofwoldrich/repos/sentry-react-native/src
/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/parsers/typescript/utils.js:114
        throw error;
        ^

TypeError: Cannot read property 'length' of undefined
    at isModuleInterface (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/parsers/typescript/modules/index.js:758:18)
    at Array.filter (<anonymous>)
    at buildModuleSchema (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/parsers/typescript/modules/index.js:773:44)
    at /Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/parsers/typescript/index.js:180:9
    at guard (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/parsers/typescript/utils.js:111:14)
    at buildSchema (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/parsers/typescript/index.js:179:22)
    at Object.parseFile (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/parsers/typescript/index.js:210:10)
    at files.reduce.modules (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/cli/combine/combine-js-to-schema.js:83:30)
    at Array.reduce (<anonymous>)
    at combineSchemas (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native-codegen/lib/cli/combine/combine-js-to-schema.js:71:16)

    at checkExecSyncError (child_process.js:790:11)
    at execSync (child_process.js:863:15)
    at executeNodeScript (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js:38:3)
    at generateSchema (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js:314:3)
    at /Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js:373:26
    at Array.forEach (<anonymous>)
    at generateNativeCodegenFiles (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js:362:13)
    at Object.execute (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js:532:5)
    at Object.<anonymous> (/Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/node_modules/react-native/scripts/generate-artifacts.js:64:10)
    at Module._compile (internal/modules/cjs/loader.js:1085:14) {
  status: 1,
  signal: null,
  output: [
    null,
    <Buffer >,
    <Buffer 2f 55 73 65 72 73 2f 6b 72 79 73 74 6f 66 77 6f 6c 64 72 69 63 68 2f 72 65 70 6f 73 2f 73 65 6e 74 72 79 2d 72 65 61 63 74 2d 6e 61 74 69 76 65 2f 73 ... 1621 more bytes>
  ],
  pid: 74656,
  stdout: <Buffer >,
  stderr: <Buffer 2f 55 73 65 72 73 2f 6b 72 79 73 74 6f 66 77 6f 6c 64 72 69 63 68 2f 72 65 70 6f 73 2f 73 65 6e 74 72 79 2d 72 65 61 63 74 2d 6e 61 74 69 76 65 2f 73 ... 1621 more bytes>
}
.

@cortinico cortinico added Tech: Codegen Related to react-native-codegen Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Oct 6, 2022
@cortinico cortinico added Partner p: Sentry Partner: Sentry labels Feb 15, 2023
@github-actions
Copy link

github-actions bot commented Sep 4, 2023

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 Sep 4, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Triage 🔍 p: Sentry Partner: Sentry Partner Stale There has been a lack of activity on this issue and it may be closed soon. 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

2 participants