rnue
Bridging JS & C++

Codegen Typings

TypeScript types supported by RNUE Codegen and their generated Unreal C++ types.

@rnue/codegen converts TypeScript types to Unreal C++ types according to the convention below.

This table complements the React Native Codegen typings reference.

Typings map

TypeScriptNullable or optional TypeScriptGenerated Unreal C++Nullable or optional Unreal C++
stringstring | null or value?: stringFStringTOptional<FString>
booleanboolean | null or value?: booleanboolTOptional<bool>
numbernumber | null or value?: numberdoubleTOptional<double>
CodegenTypes.DoubleCodegenTypes.Double | nulldoubleTOptional<double>
CodegenTypes.FloatCodegenTypes.Float | nulldoubleTOptional<double>
CodegenTypes.Int32CodegenTypes.Int32 | null or value?: CodegenTypes.Int32int32TOptional<int32>
ReadonlyArray<T> or Array<T>ReadonlyArray<T> | null or value?: ReadonlyArray<T>TArray<T>TOptional<TArray<T>>
Object alias or inline objectNullable or optional objectGenerated F structTOptional<FRecord>
Partial<RecordType>Generated F struct with optional fieldsEach optional field uses TOptional<T>
String-literal union, such as "slow" | "fast"Nullable or optional unionGenerated scoped E enumTOptional<EMode>
void returnvoid

Notes

  • CodegenTypes.Int32 uses strict conversion. The generated binding rejects fractional, non-finite, and out-of-range values.
  • Object aliases generate structs in the <Library>::Generated namespace. Field names use PascalCase, and Boolean fields use the b prefix.
  • Nested concrete records are supported. Recursive records are not supported.
  • For an applicable schema type, null or undefined produces an unset TOptional<T>.
  • An optional-only parameter accepts omission or undefined. Add null to its TypeScript type when the caller can pass null.

Runtime types

Use runtime jsi values only when the schema cannot describe a concrete value.

TypeScriptNullable or optional TypeScriptGenerated C++Notes
CodegenTypes.UnsafeObject or dictionary typeNullable or optional objectfacebook::jsi::Object or TOptional<facebook::jsi::Object>Untyped JavaScript object
CodegenTypes.UnsafeMixed or unknownNullable or optional valuefacebook::jsi::Value or TOptional<facebook::jsi::Value>Dynamic JavaScript value
Function or callbackNullable or optional functionfacebook::jsi::Function or TOptional<facebook::jsi::Function>Runtime-bound callback
Array that contains a runtime-bound typeNullable or optional arrayfacebook::jsi::Array or TOptional<facebook::jsi::Array>The complete array remains runtime-bound
Non-string unionNullable or optional unionfacebook::jsi::Value or TOptional<facebook::jsi::Value>Dynamic union value
TypeScript enumNullable or optional enumfacebook::jsi::Value or TOptional<facebook::jsi::Value>Use a string-literal union for a generated C++ enum
Direct tupleNot generatedReact Native 0.86 erases tuple element types
Array of tuplesNullable or optional arrayfacebook::jsi::Array or TOptional<facebook::jsi::Array>Tuple element types are not available to RNUE Codegen

Notes

  • A method that contains a runtime-bound type receives facebook::jsi::Runtime& Runtime.
  • A fully concrete method does not receive a JSI runtime.
  • Raw JSI values belong to that runtime and its JavaScript thread. Do not store them or move them to another thread.
  • Copy the required data to Unreal-owned values before asynchronous work starts.
  • Concrete records and event payloads cannot contain runtime-bound fields. Keep each dynamic value at a method boundary.
  • Dictionary types do not generate TMap. Callback signatures do not generate typed C++ callback wrappers.
  • any is not a supported schema type. Use CodegenTypes.UnsafeMixed when the boundary must accept dynamic data.

Generated method shapes

@rnue/codegen changes TypeScript declarations into generated IService methods and protected event helpers.

TypeScript declarationGenerated C++ service shape
setEnabled(enabled: boolean): voidvoid SetEnabled(bool bEnabled)
getName(): stringFString GetName()
getName(): string | nullTOptional<FString> GetName()
load(): Promise<Result>void Load(ReactNativeUnreal::TReactPromise<FResult> Promise)
load(): Promise<Result | null>void Load(ReactNativeUnreal::TReactPromise<TOptional<FResult>> Promise)
clear(): Promise<void>void Clear(ReactNativeUnreal::TReactPromise<void> Promise)
readonly onReading: CodegenTypes.EventEmitter<Reading>Protected bool EmitReading(FReading Value)

Notes

  • Typed Promise handles are thread-safe and settle once. They become inert when their React endpoint disconnects.
  • Use Promise.Resolve(Value) or Promise.Resolve() for success. Use Promise.Reject(ReactNativeUnreal::FReactModuleError(...)) for an error.
  • A Promise with a runtime-bound result remains a raw JSI Promise. The service returns facebook::jsi::Value.
  • The same method receives facebook::jsi::Runtime& Runtime and const std::shared_ptr<facebook::react::CallInvoker>& JsInvoker.
  • Event emitters and their payloads are not nullable. Event payloads must use concrete types.
  • JavaScript receives an EventSubscription and must call remove() during cleanup.

Naming rules

@rnue/codegen uses the following C++ naming rules:

  • TypeScript methods become PascalCase C++ methods.
  • Object aliases become structs with an F prefix.
  • String-literal unions become scoped enums with an E prefix.
  • Object fields become PascalCase members.
  • Boolean parameters and fields use the b prefix.
  • Generated types use the <Library>::Generated namespace.