Skip to content

Commit

Permalink
rebuild codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
vonovak committed Feb 24, 2025
1 parent 4bfe3bf commit e8d86f4
Show file tree
Hide file tree
Showing 84 changed files with 2,338 additions and 386 deletions.
99 changes: 60 additions & 39 deletions packages/react-native-codegen/lib/CodegenSchema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ export interface StringTypeAnnotation {
readonly type: 'StringTypeAnnotation';
}

export interface StringEnumTypeAnnotation {
readonly type: 'StringEnumTypeAnnotation';
readonly options: readonly string[];
}

export interface VoidTypeAnnotation {
readonly type: 'VoidTypeAnnotation';
}
Expand Down Expand Up @@ -127,16 +122,11 @@ export type EventTypeAnnotation =
| FloatTypeAnnotation
| Int32TypeAnnotation
| MixedTypeAnnotation
| StringEnumTypeAnnotation
| StringLiteralUnionTypeAnnotation
| ObjectTypeAnnotation<EventTypeAnnotation>
| {
readonly type: 'ArrayTypeAnnotation';
readonly elementType: EventTypeAnnotation
};
| ArrayTypeAnnotation<EventTypeAnnotation>

export type ArrayTypeAnnotation = {
readonly type: 'ArrayTypeAnnotation';
readonly elementType:
export type ComponentArrayTypeAnnotation = ArrayTypeAnnotation<
| BooleanTypeAnnotation
| StringTypeAnnotation
| DoubleTypeAnnotation
Expand All @@ -149,10 +139,25 @@ export type ArrayTypeAnnotation = {
}
| ObjectTypeAnnotation<PropTypeAnnotation>
| ReservedPropTypeAnnotation
| {
readonly type: 'ArrayTypeAnnotation';
readonly elementType: ObjectTypeAnnotation<PropTypeAnnotation>;
};
| ArrayTypeAnnotation<ObjectTypeAnnotation<PropTypeAnnotation>>
>;

export type ComponentCommandArrayTypeAnnotation = ArrayTypeAnnotation<
| BooleanTypeAnnotation
| StringTypeAnnotation
| DoubleTypeAnnotation
| FloatTypeAnnotation
| Int32TypeAnnotation
// Mixed is not great. This generally means its a type alias to another type
// like an object or union. Ideally we'd encode that type in the schema so the compat-check can
// validate those deeper objects for breaking changes and the generators can do something smarter.
// As of now, the generators just create ReadableMap or (const NSArray *) which are untyped
| MixedTypeAnnotation
>;

export interface ArrayTypeAnnotation<T> {
readonly type: 'ArrayTypeAnnotation';
readonly elementType: T;
}

export type PropTypeAnnotation =
Expand Down Expand Up @@ -188,7 +193,7 @@ export type PropTypeAnnotation =
}
| ReservedPropTypeAnnotation
| ObjectTypeAnnotation<PropTypeAnnotation>
| ArrayTypeAnnotation
| ComponentArrayTypeAnnotation
| MixedTypeAnnotation;

export interface ReservedPropTypeAnnotation {
Expand All @@ -214,7 +219,7 @@ export type CommandParamTypeAnnotation =
| DoubleTypeAnnotation
| FloatTypeAnnotation
| StringTypeAnnotation
| ArrayTypeAnnotation;
| ComponentCommandArrayTypeAnnotation;

export interface ReservedTypeAnnotation {
readonly type: 'ReservedTypeAnnotation';
Expand Down Expand Up @@ -273,23 +278,36 @@ export type NativeModuleObjectTypeAnnotation = ObjectTypeAnnotation<
Nullable<NativeModuleBaseTypeAnnotation>
>;

export interface NativeModuleArrayTypeAnnotation<T extends Nullable<NativeModuleBaseTypeAnnotation>> {
readonly type: 'ArrayTypeAnnotation';
/**
* TODO(T72031674): Migrate all our NativeModule specs to not use
* invalid Array ElementTypes. Then, make the elementType required.
*/
readonly elementType: T | UnsafeAnyTypeAnnotation;
}
/**
* TODO(T72031674): Migrate all our NativeModule specs to not use
* invalid Array ElementTypes. Then, make the elementType required.
*/
interface NativeModuleArrayTypeAnnotation<T> extends ArrayTypeAnnotation<T | UnsafeAnyTypeAnnotation> { }


export interface UnsafeAnyTypeAnnotation {
readonly type: 'AnyTypeAnnotation',
}

export interface NativeModuleNumberLiteralTypeAnnotation {
readonly type: 'NumberLiteralTypeAnnotation';
readonly value: number;
}

export interface NativeModuleStringTypeAnnotation {
readonly type: 'StringTypeAnnotation';
}

export interface NativeModuleStringLiteralTypeAnnotation {
readonly type: 'StringLiteralTypeAnnotation';
readonly value: string;
}

export interface StringLiteralUnionTypeAnnotation {
readonly type: 'StringLiteralUnionTypeAnnotation';
readonly types: NativeModuleStringLiteralTypeAnnotation[];
}

export interface NativeModuleNumberTypeAnnotation {
readonly type: 'NumberTypeAnnotation';
}
Expand All @@ -310,10 +328,10 @@ export interface NativeModuleBooleanTypeAnnotation {
readonly type: 'BooleanTypeAnnotation';
}

export type NativeModuleEnumMembers = readonly {
export type NativeModuleEnumMember = {
readonly name: string;
readonly value: string | number;
}[];
readonly value: NativeModuleStringLiteralTypeAnnotation | NativeModuleNumberLiteralTypeAnnotation,
};

export type NativeModuleEnumMemberType =
| 'NumberTypeAnnotation'
Expand All @@ -329,7 +347,7 @@ export interface NativeModuleEnumDeclarationWithMembers {
name: string;
type: 'EnumDeclarationWithMembers';
memberType: NativeModuleEnumMemberType;
members: NativeModuleEnumMembers;
members: readonly NativeModuleEnumMember[];
}

export interface NativeModuleGenericObjectTypeAnnotation {
Expand All @@ -347,7 +365,7 @@ export interface NativeModuleTypeAliasTypeAnnotation {

export interface NativeModulePromiseTypeAnnotation {
readonly type: 'PromiseTypeAnnotation';
readonly elementType?: Nullable<NativeModuleBaseTypeAnnotation> | undefined;
readonly elementType: Nullable<NativeModuleBaseTypeAnnotation> | VoidTypeAnnotation;
}

export type UnionTypeAnnotationMemberType =
Expand All @@ -370,21 +388,24 @@ export type NativeModuleEventEmitterBaseTypeAnnotation =
| NativeModuleFloatTypeAnnotation
| NativeModuleInt32TypeAnnotation
| NativeModuleNumberTypeAnnotation
| NativeModuleNumberLiteralTypeAnnotation
| NativeModuleStringTypeAnnotation
| NativeModuleStringLiteralTypeAnnotation
| StringLiteralUnionTypeAnnotation
| NativeModuleTypeAliasTypeAnnotation
| NativeModuleGenericObjectTypeAnnotation
| VoidTypeAnnotation;

export type NativeModuleEventEmitterTypeAnnotation =
| NativeModuleEventEmitterBaseTypeAnnotation
| {
readonly type: 'ArrayTypeAnnotation';
readonly elementType: NativeModuleEventEmitterBaseTypeAnnotation;
};
| ArrayTypeAnnotation<NativeModuleEventEmitterBaseTypeAnnotation>;

export type NativeModuleBaseTypeAnnotation =
| NativeModuleStringTypeAnnotation
NativeModuleStringTypeAnnotation
| NativeModuleStringLiteralTypeAnnotation
| StringLiteralUnionTypeAnnotation
| NativeModuleNumberTypeAnnotation
| NativeModuleNumberLiteralTypeAnnotation
| NativeModuleInt32TypeAnnotation
| NativeModuleDoubleTypeAnnotation
| NativeModuleFloatTypeAnnotation
Expand All @@ -393,10 +414,10 @@ export type NativeModuleBaseTypeAnnotation =
| NativeModuleGenericObjectTypeAnnotation
| ReservedTypeAnnotation
| NativeModuleTypeAliasTypeAnnotation
| NativeModuleArrayTypeAnnotation<Nullable<NativeModuleBaseTypeAnnotation>>
| NativeModuleObjectTypeAnnotation
| NativeModuleUnionTypeAnnotation
| NativeModuleMixedTypeAnnotation;
| NativeModuleMixedTypeAnnotation
| NativeModuleArrayTypeAnnotation<NativeModuleBaseTypeAnnotation>;

export type NativeModuleParamTypeAnnotation =
| NativeModuleBaseTypeAnnotation
Expand Down
Loading

0 comments on commit e8d86f4

Please sign in to comment.