refactor: Renamed emitObject to emitGenericObject (#35981)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/35981 This reflects better what the former `emitObject` was doing - emitting a generic object. It would also allow us to rename `emitPartial` to `emitObject` in the next diff whence the function name `emitObject` will be free. Changelog: [Internal] - Renamed emitObject to emitGenericObject Reviewed By: christophpurrer Differential Revision: D42740871 fbshipit-source-id: 1b9112464695b8abeccc95eed908b0b45a0e3bf2
This commit is contained in:
Родитель
9856c334bd
Коммит
84c1547526
|
@ -20,7 +20,7 @@ const {
|
|||
emitFloat,
|
||||
emitNumber,
|
||||
emitInt32,
|
||||
emitObject,
|
||||
emitGenericObject,
|
||||
emitPartial,
|
||||
emitPromise,
|
||||
emitRootTag,
|
||||
|
@ -431,10 +431,10 @@ describe('emitPromise', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('emitObject', () => {
|
||||
describe('emitGenericObject', () => {
|
||||
describe('when nullable is true', () => {
|
||||
it('returns nullable type annotation', () => {
|
||||
const result = emitObject(true);
|
||||
const result = emitGenericObject(true);
|
||||
const expected = {
|
||||
type: 'NullableTypeAnnotation',
|
||||
typeAnnotation: {
|
||||
|
@ -447,7 +447,7 @@ describe('emitObject', () => {
|
|||
});
|
||||
describe('when nullable is false', () => {
|
||||
it('returns non nullable type annotation', () => {
|
||||
const result = emitObject(false);
|
||||
const result = emitGenericObject(false);
|
||||
const expected = {
|
||||
type: 'GenericObjectTypeAnnotation',
|
||||
};
|
||||
|
|
|
@ -41,7 +41,7 @@ const {
|
|||
emitFunction,
|
||||
emitNumber,
|
||||
emitInt32,
|
||||
emitObject,
|
||||
emitGenericObject,
|
||||
emitPartial,
|
||||
emitPromise,
|
||||
emitRootTag,
|
||||
|
@ -154,7 +154,7 @@ function translateTypeAnnotation(
|
|||
}
|
||||
case 'UnsafeObject':
|
||||
case 'Object': {
|
||||
return emitObject(nullable);
|
||||
return emitGenericObject(nullable);
|
||||
}
|
||||
case '$Partial': {
|
||||
if (typeAnnotation.typeParameters.params.length !== 1) {
|
||||
|
@ -221,7 +221,7 @@ function translateTypeAnnotation(
|
|||
parser,
|
||||
);
|
||||
// no need to do further checking
|
||||
return emitObject(nullable);
|
||||
return emitGenericObject(nullable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,7 @@ function translateTypeAnnotation(
|
|||
if (cxxOnly) {
|
||||
return emitMixed(nullable);
|
||||
} else {
|
||||
return emitObject(nullable);
|
||||
return emitGenericObject(nullable);
|
||||
}
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -236,7 +236,7 @@ function emitPromise(
|
|||
}
|
||||
}
|
||||
|
||||
function emitObject(
|
||||
function emitGenericObject(
|
||||
nullable: boolean,
|
||||
): Nullable<NativeModuleGenericObjectTypeAnnotation> {
|
||||
return wrapNullable(nullable, {
|
||||
|
@ -380,7 +380,7 @@ module.exports = {
|
|||
emitFunction,
|
||||
emitInt32,
|
||||
emitNumber,
|
||||
emitObject,
|
||||
emitGenericObject,
|
||||
emitPartial,
|
||||
emitPromise,
|
||||
emitRootTag,
|
||||
|
|
|
@ -41,7 +41,7 @@ const {
|
|||
emitFunction,
|
||||
emitNumber,
|
||||
emitInt32,
|
||||
emitObject,
|
||||
emitGenericObject,
|
||||
emitPartial,
|
||||
emitPromise,
|
||||
emitRootTag,
|
||||
|
@ -171,7 +171,7 @@ function translateTypeAnnotation(
|
|||
}
|
||||
case 'UnsafeObject':
|
||||
case 'Object': {
|
||||
return emitObject(nullable);
|
||||
return emitGenericObject(nullable);
|
||||
}
|
||||
case 'Partial': {
|
||||
if (typeAnnotation.typeParameters.params.length !== 1) {
|
||||
|
@ -275,7 +275,7 @@ function translateTypeAnnotation(
|
|||
parser,
|
||||
);
|
||||
// no need to do further checking
|
||||
return emitObject(nullable);
|
||||
return emitGenericObject(nullable);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче