react-native-windows
react-native-windows copied to clipboard
react-native codegen GUID and symbol types
Summary
These two types would be ergonomically convenient for TurboModules -- there's ways around through strings and type workarounds but it's cumbersome to do that.
Motivation
The GUID type would be convenient type to avoid parsing/constructing strings in native code manually.
The symbol type would be convenient as an opaque type, similar to PlatformColor when referencing brushes or high contrast color types without openly exposing the details of the JS-side representation for manipulation.
Basic Example
The symbol type I'm working around with my own type written as:
type OpaqueFooTypeDef = symbol & { __TYPE__: "Foo" };
export type OpaqueFooType =
| OpaqueFooTypeDef
| OpaqueFooTypeDef;
though I also can't export that type and share it across module definitions so that's a little annoying.
Open Questions
No response
First question is how is this handled upstream with RN core. Are these types supported by their native codegen? And if not, what does it means for Windows to not match / extend?
OpaqueColorValue used by the ColorValue type to support PlatformColor was my guide. I haven't had a chance to try using the native codegen with a local turbomodule gap blocking comparable re-use on MacOS (I believe MacOS re-uses the common iOS native codegen)