How to define custom types when defining spec for turbo modules

83 views Asked by At

I am trying to define a turbo module spec file in react native(new architecture). Sample code below

// file: NativeCustomSpec.ts
export interface Spec extends TurboModule {

  initialize(configs: MyCustomConfig): Promise<void>;
}

// MyCustomConfigs type
class CastledConfig {
  stringField: string = '';
  stringField2: '';
  boolField: boolean = false;
  numberField: number = 0;
}

When I use codegen to generate the code using spec file, I get the following error Unrecognized generic type 'MyCustomConfig' in NativeModule spec.

In case of the legacy react native module, you typically use a ReadableMap for the native implementation of the corresponding method for the custom type.

Any workarounds for this in the new turbo module architecture.

0

There are 0 answers