Codegen chokes on imported types
未关闭
@dmytrorykun 已经在做这个了。
开始于 2023年10月30日。
Needs: React Native Team Attention
Never gets stale
Tech: Codegen
Type: New Architecture
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
评估
这个 Issue 还没有评估数据。