Codegen Missing Features #91
-
In the context of supporting the migration to the New Architecture, we figured out that CodeGen is missing some important features that can be quite helpful for any library developer. This thread would like to work as an open thread where we can collect the missing features and their use cases. This will help us to:
To post in the thread, please follow this structure: Missing Feature: < What do you want to be implemented > |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 24 replies
-
|
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
-
Tested Missing Feature: Types from another file does not work. Imported types are not recognized by the CodeGen.
Keeping all types in one file can make our code unmaintainable. Right now, all types are kept in a separate file to keep the code clean and readable. |
Beta Was this translation helpful? Give feedback.
-
Tested Missing Feature: Struct operator Use Cases: NativeComponent.ts type ColorFiltersStruct {
colorFilters?: ReadonlyArray<Readonly<{ keypath: string; color: string }>>
} ComponentView.mm if(newProps.colorFilters != oldProps.colorFilters) {
...
} The build fails with an error similar to this one
|
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
Missing Feature: Support non-root interface of DirectEventHandler The following currently works: interface Frame {
height: Double;
width: Double;
}
onPress: DirectEventHandler<Frame>; interface Frame {
height: Double;
width: Double;
}
onPress: DirectEventHandler<{
someString: string;
frame: {
height: Double;
width: Double;
};
}>; While the following throws: interface Frame {
height: Double;
width: Double;
}
onPress: DirectEventHandler<{
someString: string;
frame: Frame;
}>; Use Cases: Needed for non-trivial event types. |
Beta Was this translation helpful? Give feedback.
-
Missing Feature: Support objects in NativeCommands I might be missing something obvious (and if I do, please don't hesitate to let me know), but it seems impossible to specify any sort of object when using NativeCommands? The following all fails: interface NativeCommands {
animateToRegion: (
viewRef: React.ElementRef<MyView>,
region: Object,
) => void;
}
interface NativeCommands {
animateToRegion: (
viewRef: React.ElementRef<MyView>,
region: UnsafeObject,
) => void;
}
interface NativeCommands {
animateToRegion: (
viewRef: React.ElementRef<MyView>,
region: object,
) => void;
}
interface Region {
latitude: Double;
longitude: Double;
latitudeDelta: Double;
longitudeDelta: Double;
}
interface NativeCommands {
animateToRegion: (
viewRef: React.ElementRef<MyView>,
region: Region,
) => void;
}
interface NativeCommands {
animateToRegion: (
viewRef: React.ElementRef<MyView>,
region: {
latitude: Double;
longitude: Double;
latitudeDelta: Double;
longitudeDelta: Double;
},
) => void;
}
|
Beta Was this translation helpful? Give feedback.
-
Chiming in here, as I've noticed that Codegen is incompatible with the following types, unless I'm doing something wrong:
At the moment, I'm working through trial and error to see which parts of our method interfaces are not compatible, but are there are any resources/documentation to fully understand what throws a parser error? |
Beta Was this translation helpful? Give feedback.
-
Generate code without requiring a (dummy) app. Or if the app is really required then write the reason in this page https://github.com/reactwg/react-native-new-architecture/blob/main/docs/turbo-modules.md Context: I am playing with the Turbo module by following this page: https://github.com/reactwg/react-native-new-architecture/blob/main/docs/turbo-modules.md - I have not created any React Native app in this context so far.
... a React Native application seems to be required for the codegen; Why? |
Beta Was this translation helpful? Give feedback.
-
Use Earlier today I was trying to pass a jsi HostObject to the method of a view command, but found out that thats not possible (while using it as return value seems to be fine): |
Beta Was this translation helpful? Give feedback.
@hannojg I'll copy my answer from a different discussion:
The
Command
abstraction is a way to tell a native component to do something bypassing the renderer. You should not expect any return value from it. The return value from a command generally may depend on many things other than component itself. This makes such component non-composable. This breaks one of React's fundamental principles. This is also the reason why it only accepts primitive types. We may add some more capabilities in the future, but there are currently no plans for that.I would recommend to try finding a way to implement this behaviour using Native Modules.