Skip to content

react-native codegen GUID and symbol types #14656

@PPatBoyd

Description

@PPatBoyd

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions