Add a test for an Alias to an Alias (#46725)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46725

This covers types that deeply alias.

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D62926913

fbshipit-source-id: 2fea1900f1be2893230a949db6778c76afae0423
This commit is contained in:
Eli White
2024-09-30 11:19:44 -07:00
committed by Facebook GitHub Bot
parent 544c4ff75b
commit c658e87518
4 changed files with 44 additions and 0 deletions
@@ -162,6 +162,7 @@ export type ObjectAlias = {|
label: string,
truthy: boolean,
|};
export type PureObjectAlias = ObjectAlias;
export type ReadOnlyAlias = $ReadOnly<ObjectAlias>;
export interface Spec extends TurboModule {
@@ -171,6 +172,7 @@ export interface Spec extends TurboModule {
+getArray: (a: Array<A>) => {| a: B |};
+getStringFromAlias: (a: ObjectAlias) => string;
+getStringFromNullableAlias: (a: ?ObjectAlias) => string;
+getStringFromPureAlias: (a: PureObjectAlias) => string;
+getStringFromReadOnlyAlias: (a: ReadOnlyAlias) => string;
+getStringFromNullableReadOnlyAlias: (a: ?ReadOnlyAlias) => string;
}
@@ -688,6 +688,26 @@ exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_ALIASES
]
}
},
{
'name': 'getStringFromPureAlias',
'optional': false,
'typeAnnotation': {
'type': 'FunctionTypeAnnotation',
'returnTypeAnnotation': {
'type': 'StringTypeAnnotation'
},
'params': [
{
'name': 'a',
'optional': false,
'typeAnnotation': {
'type': 'TypeAliasTypeAnnotation',
'name': 'ObjectAlias'
}
}
]
}
},
{
'name': 'getStringFromReadOnlyAlias',
'optional': false,
@@ -146,6 +146,7 @@ export type ObjectAlias = {
label: string;
truthy: boolean;
};
export type PureObjectAlias = ObjectAlias;
export type ReadOnlyAlias = Readonly<ObjectAlias>;
export interface Spec extends TurboModule {
@@ -155,6 +156,7 @@ export interface Spec extends TurboModule {
readonly getArray: (a: Array<A>) => {a: B};
readonly getStringFromAlias: (a: ObjectAlias) => string;
readonly getStringFromNullableAlias: (a: ObjectAlias | null) => string;
readonly getStringFromPureAlias: (a: PureObjectAlias) => string;
readonly getStringFromReadOnlyAlias: (a: ReadOnlyAlias) => string;
readonly getStringFromNullableReadOnlyAlias: (a: ReadOnlyAlias | null) => string;
}
@@ -679,6 +679,26 @@ exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_AL
]
}
},
{
'name': 'getStringFromPureAlias',
'optional': false,
'typeAnnotation': {
'type': 'FunctionTypeAnnotation',
'returnTypeAnnotation': {
'type': 'StringTypeAnnotation'
},
'params': [
{
'name': 'a',
'optional': false,
'typeAnnotation': {
'type': 'TypeAliasTypeAnnotation',
'name': 'ObjectAlias'
}
}
]
}
},
{
'name': 'getStringFromReadOnlyAlias',
'optional': false,