react-native-windows icon indicating copy to clipboard operation
react-native-windows copied to clipboard

react-native codegen GUID and symbol types

Open PPatBoyd opened this issue 6 months ago • 2 comments
trafficstars

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

PPatBoyd avatar May 09 '25 19:05 PPatBoyd

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?

chrisglein avatar May 19 '25 18:05 chrisglein

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)

PPatBoyd avatar Jun 10 '25 19:06 PPatBoyd