mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Refactor: Make NativeModuleAliasMap $ReadOnly
Summary: We were using `$ReadOnly<NativeModuleAliasMap>` everywhere, so I figured we'd just make the type itself `$ReadOnly`. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D23645207 fbshipit-source-id: 4e018d5768f4fcfd00492def7d840a5054cb2b73
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2e0fb69365
commit
92a6722bf2
+3
-3
@@ -267,13 +267,13 @@ export type Required<T> = $ReadOnly<{...T, nullable: false}>;
|
||||
|
||||
export type NativeModuleSchema = $ReadOnly<{|
|
||||
// We only support aliases to Objects
|
||||
aliases: $ReadOnly<NativeModuleAliasMap>,
|
||||
aliases: NativeModuleAliasMap,
|
||||
properties: $ReadOnlyArray<NativeModulePropertySchema>,
|
||||
|}>;
|
||||
|
||||
export type NativeModuleAliasMap = {
|
||||
export type NativeModuleAliasMap = $ReadOnly<{|
|
||||
[aliasName: string]: Required<NativeModuleObjectTypeAnnotation>,
|
||||
};
|
||||
|}>;
|
||||
|
||||
export type NativeModulePropertySchema = $ReadOnly<{|
|
||||
name: string,
|
||||
|
||||
@@ -38,7 +38,7 @@ function translateTypeAnnotation(
|
||||
*/
|
||||
flowTypeAnnotation: $FlowFixMe,
|
||||
types: TypeDeclarationMap,
|
||||
aliasMap: NativeModuleAliasMap,
|
||||
aliasMap: {...NativeModuleAliasMap},
|
||||
): NativeModuleTypeAnnotation {
|
||||
const {
|
||||
nullable,
|
||||
@@ -306,7 +306,7 @@ function translateFunctionTypeAnnotation(
|
||||
flowFunctionTypeAnnotation: $FlowFixMe,
|
||||
types: TypeDeclarationMap,
|
||||
nullable: boolean,
|
||||
aliasMap: NativeModuleAliasMap,
|
||||
aliasMap: {...NativeModuleAliasMap},
|
||||
): NativeModuleFunctionTypeAnnotation {
|
||||
const params: Array<NativeModuleMethodParamSchema> = [];
|
||||
for (const flowParam of (flowFunctionTypeAnnotation.params: $ReadOnlyArray<$FlowFixMe>)) {
|
||||
@@ -367,7 +367,7 @@ function buildPropertySchema(
|
||||
// Flow type this node
|
||||
property: $FlowFixMe,
|
||||
types: TypeDeclarationMap,
|
||||
aliasMap: NativeModuleAliasMap,
|
||||
aliasMap: {...NativeModuleAliasMap},
|
||||
): NativeModulePropertySchema {
|
||||
let nullable = false;
|
||||
let {key, value} = property;
|
||||
@@ -422,7 +422,7 @@ function buildModuleSchema(
|
||||
return (declaration.body.properties: $ReadOnlyArray<$FlowFixMe>)
|
||||
.filter(property => property.type === 'ObjectTypeProperty')
|
||||
.map(property => {
|
||||
const aliasMap: NativeModuleAliasMap = {};
|
||||
const aliasMap: {...NativeModuleAliasMap} = {};
|
||||
return {
|
||||
aliasMap: aliasMap,
|
||||
propertySchema: buildPropertySchema(
|
||||
|
||||
Reference in New Issue
Block a user