Closed
Description
Description
I'm trying to use the codegen to generate a TurboModule with the following type:
export type WindowBounds = {
x: number;
y: number;
width: number;
height: number;
};
export type WindowBoundsPartial = Partial<WindowBounds>;
But it fails with the error:
UnsupportedGenericParserError: Module NativeWindowModule: Unrecognized generic type 'Partial' in NativeModule spec.
This is a great feature that's supported both in TS (https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype) and flow (https://flow.org/en/docs/types/utilities/#toc-partial).
Without this feature, I'll have to rewrite the type as
export type WindowBoundsPartial = {
x?: number;
y?: number;
width?: number;
height?: number;
};
I also tried defining Partial
by myself:
type Partial2<T> = {
[P in keyof T]?: T[P];
};
export type WindowBoundsPartial = Partial2<WindowBounds>;
But this fails too with the error:
UnsupportedTypeAnnotationParserError: Module NativeWindowModule: TypeScript type annotation 'TSMappedType' is unsupported in NativeModule specs.
Version
latest
Output of npx react-native info
n.a
Steps to reproduce
- add
export type WindowBounds = {
x: number;
y: number;
width: number;
height: number;
};
export type WindowBoundsPartial = Partial<WindowBounds>;
to any Turbo Module spec file
- try to run the codegen
Snack, code example, screenshot, or link to a repository
export type WindowBounds = {
x: number;
y: number;
width: number;
height: number;
};
export type WindowBoundsPartial = Partial<WindowBounds>;