Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/asset-utils/src/AndroidPathUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type PackagerAsset = Readonly<{
}>;
*/

const androidScaleSuffix /*: {[string]: string} */ = {
const androidScaleSuffix /*: {[key: string]: string} */ = {
'0.75': 'ldpi',
'1': 'mdpi',
'1.5': 'hdpi',
Expand Down
4 changes: 2 additions & 2 deletions packages/debugger-shell/src/electron/SettingsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ export default class SettingsStore {
}
}

get store(): {[string]: unknown} {
get store(): {[key: string]: unknown} {
try {
const data = fs.readFileSync(this.path, 'utf8');
const deserializedData = this._deserialize(data);
return {
...(deserializedData as any as {[string]: unknown}),
...(deserializedData as any as {[key: string]: unknown}),
};
} catch (error) {
if (error?.code === 'ENOENT') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class DebuggerAgent {
constructor(
url: string,
signal?: AbortSignal,
headers?: ?{[string]: unknown},
headers?: ?{[key: string]: unknown},
) {
const ws = new WebSocket(url, {
// The mock server uses a self-signed certificate.
Expand Down Expand Up @@ -122,7 +122,7 @@ export class DebuggerMock extends DebuggerAgent {
export async function createDebuggerMock(
url: string,
signal: AbortSignal,
headers?: ?{[string]: unknown},
headers?: ?{[key: string]: unknown},
): Promise<DebuggerMock> {
const debuggerMock = new DebuggerMock(url, signal, headers);
await debuggerMock.ready();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export async function createAndConnectTarget(
deviceId = null,
deviceHostHeader = null,
}: Readonly<{
debuggerHeaders?: ?{[string]: unknown},
debuggerHeaders?: ?{[key: string]: unknown},
debuggerOriginHeader?: ?string,
deviceId?: ?string,
deviceHostHeader?: ?string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function getCDPLogPrefix(destination: CDPMessageDestination): string {

export default class CdpDebugLogging {
#cdpMessagesLoggingBatchingFn: {
[CDPMessageDestination]: (message: string) => void,
[key: CDPMessageDestination]: (message: string) => void,
} = {
DebuggerToProxy: () => {},
ProxyToDebugger: () => {},
Expand All @@ -55,7 +55,7 @@ export default class CdpDebugLogging {

#initializeThrottledCDPMessageLogging(): void {
const batchingCounters: {
[CDPMessageDestination]: {count: number, size: number},
[key: CDPMessageDestination]: {count: number, size: number},
} = {
DebuggerToProxy: {count: 0, size: 0},
ProxyToDebugger: {count: 0, size: 0},
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-middleware/src/inspector-proxy/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export type JSONSerializable =
| string
| null
| ReadonlyArray<JSONSerializable>
| {readonly [string]: JSONSerializable};
| {readonly [key: string]: JSONSerializable};

export type DeepReadOnly<T> =
T extends ReadonlyArray<infer V>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ test(`isolated preset loads when the consumer provides react-native (${RN_ISSUE}
// Strip resolution-affecting env so the child is genuinely isolated:
// inherited lookup paths can otherwise make the copy resolve more
// than the directory layout alone provides.
const childEnv: {[string]: string} = {};
const childEnv: {[key: string]: string} = {};
for (const key of Object.keys(process.env)) {
if (key === 'NODE_PATH' || key === 'NODE_OPTIONS') {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const MOCK_FILENAME = '/absolute/path/to/input.js';

function transformWithCaller(
code: string,
options: {[string]: unknown},
options: {[key: string]: unknown},
caller: {
enableBabelRuntime?: boolean | string,
babelRuntimeModuleName?: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const testConfigs = [

function transformCode(
code: string,
options: {[string]: unknown},
options: {[key: string]: unknown},
): string | null {
const result = babel.transformSync(code, {
babelrc: false,
Expand All @@ -173,7 +173,7 @@ function transformCode(

function transformCodeWithSourceOptimization(
code: string,
options: {[string]: unknown},
options: {[key: string]: unknown},
): string | null {
const config = preset.getPreset(code, options);
const result = babel.transformSync(code, {
Expand Down Expand Up @@ -208,7 +208,10 @@ function ensureDirectoryExists(dir: string): void {
}
}

function makeHeader(description: string, options: {[string]: unknown}): string {
function makeHeader(
description: string,
options: {[key: string]: unknown},
): string {
return `/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
Expand Down
6 changes: 3 additions & 3 deletions packages/react-native-codegen/src/generators/RNCodegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export type GenerateFunction = (
) => FilesOutput;

export type LibraryGeneratorsFunctions = Readonly<{
[string]: Array<GenerateFunction>,
[key: string]: Array<GenerateFunction>,
}>;

export type LibraryOptions = Readonly<{
Expand All @@ -92,9 +92,9 @@ export type LibraryOptions = Readonly<{
}>;

export type SchemasOptions = Readonly<{
schemas: {[string]: SchemaType},
schemas: {[key: string]: SchemaType},
outputDirectory: string,
supportedApplePlatforms?: {[string]: {[string]: boolean}},
supportedApplePlatforms?: {[key: string]: {[key: string]: boolean}},
}>;

export type LibraryGenerators =
Expand Down
141 changes: 70 additions & 71 deletions packages/react-native-codegen/src/generators/ReservedPrimitiveTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,83 +43,82 @@ type ReservedTypeMapping = {
readonly java: JavaImportInfo,
};

const RESERVED_TYPES: {readonly [ReservedPrimitiveName]: ReservedTypeMapping} =
{
ColorPrimitive: {
cpp: {
typeName: 'SharedColor',
localIncludes: ['#include <React/Graphics.h>'],
conversionIncludes: [],
},
java: {
interfaceImports: [],
delegateImports: [
'import com.facebook.react.bridge.ColorPropConverter;',
],
},
const RESERVED_TYPES: {
readonly [key: ReservedPrimitiveName]: ReservedTypeMapping,
} = {
ColorPrimitive: {
cpp: {
typeName: 'SharedColor',
localIncludes: ['#include <React/Graphics.h>'],
conversionIncludes: [],
},
ImageSourcePrimitive: {
cpp: {
typeName: 'ImageSource',
localIncludes: ['#include <React/ImageManager.h>'],
conversionIncludes: ['#include <React/Image.h>'],
},
java: {
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
},
java: {
interfaceImports: [],
delegateImports: ['import com.facebook.react.bridge.ColorPropConverter;'],
},
ImageRequestPrimitive: {
cpp: {
typeName: 'ImageRequest',
localIncludes: ['#include <React/ImageManager.h>'],
conversionIncludes: [],
},
java: {
// ImageRequestPrimitive is not used in Java component props
interfaceImports: [],
delegateImports: [],
},
},
ImageSourcePrimitive: {
cpp: {
typeName: 'ImageSource',
localIncludes: ['#include <React/ImageManager.h>'],
conversionIncludes: ['#include <React/Image.h>'],
},
PointPrimitive: {
cpp: {
typeName: 'Point',
localIncludes: ['#include <React/Graphics.h>'],
conversionIncludes: [],
},
java: {
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
},
java: {
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
},
EdgeInsetsPrimitive: {
cpp: {
typeName: 'EdgeInsets',
localIncludes: ['#include <React/Graphics.h>'],
conversionIncludes: [],
},
java: {
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
},
},
ImageRequestPrimitive: {
cpp: {
typeName: 'ImageRequest',
localIncludes: ['#include <React/ImageManager.h>'],
conversionIncludes: [],
},
DimensionPrimitive: {
cpp: {
typeName: 'YGValue',
localIncludes: [
'#include <yoga/Yoga.h>',
'#include <React/RendererCore.h>',
],
conversionIncludes: ['#include <React/View.h>'],
},
java: {
interfaceImports: ['import com.facebook.yoga.YogaValue;'],
delegateImports: [
'import com.facebook.react.bridge.DimensionPropConverter;',
],
},
java: {
// ImageRequestPrimitive is not used in Java component props
interfaceImports: [],
delegateImports: [],
},
};
},
PointPrimitive: {
cpp: {
typeName: 'Point',
localIncludes: ['#include <React/Graphics.h>'],
conversionIncludes: [],
},
java: {
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
},
},
EdgeInsetsPrimitive: {
cpp: {
typeName: 'EdgeInsets',
localIncludes: ['#include <React/Graphics.h>'],
conversionIncludes: [],
},
java: {
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
},
},
DimensionPrimitive: {
cpp: {
typeName: 'YGValue',
localIncludes: [
'#include <yoga/Yoga.h>',
'#include <React/RendererCore.h>',
],
conversionIncludes: ['#include <React/View.h>'],
},
java: {
interfaceImports: ['import com.facebook.yoga.YogaValue;'],
delegateImports: [
'import com.facebook.react.bridge.DimensionPropConverter;',
],
},
},
};

function getCppTypeForReservedPrimitive(name: ReservedPrimitiveName): string {
return RESERVED_TYPES[name].cpp.typeName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const APPLE_PLATFORMS_MACRO_MAP = {
*/
function generateSupportedApplePlatformsMacro(
fileTemplate: string,
supportedPlatformsMap: ?{[string]: boolean},
supportedPlatformsMap: ?{[key: string]: boolean},
): string {
if (!supportedPlatformsMap) {
return fileTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ Class<RCTComponentViewProtocol> ${className}Cls(void) __attribute__((used)); //

module.exports = {
generate(
schemas: {[string]: SchemaType},
supportedApplePlatforms?: {[string]: {[string]: boolean}},
schemas: {[key: string]: SchemaType},
supportedApplePlatforms?: {[key: string]: {[key: string]: boolean}},
): FilesOutput {
const fileName = 'RCTThirdPartyFabricComponentsProvider.h';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ const LookupMapTemplate = ({

module.exports = {
generate(
schemas: {[string]: SchemaType},
supportedApplePlatforms?: {[string]: {[string]: boolean}},
schemas: {[key: string]: SchemaType},
supportedApplePlatforms?: {[key: string]: {[key: string]: boolean}},
): FilesOutput {
const fileName = 'RCTThirdPartyFabricComponentsProvider.mm';

Expand Down
19 changes: 9 additions & 10 deletions packages/react-native-codegen/src/generators/modules/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,16 @@ function createAliasResolver(aliasMap: NativeModuleAliasMap): AliasResolver {
function getModules(
schema: SchemaType,
): Readonly<{[hasteModuleName: string]: NativeModuleSchema}> {
return Object.keys(schema.modules).reduce<{[string]: NativeModuleSchema}>(
(modules, hasteModuleName: string) => {
const module = schema.modules[hasteModuleName];
if (module == null || module.type === 'Component') {
return modules;
}
modules[hasteModuleName] = module;
return Object.keys(schema.modules).reduce<{
[key: string]: NativeModuleSchema,
}>((modules, hasteModuleName: string) => {
const module = schema.modules[hasteModuleName];
if (module == null || module.type === 'Component') {
return modules;
},
{},
);
}
modules[hasteModuleName] = module;
return modules;
}, {});
}

function isDirectRecursiveMember(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -985,14 +985,14 @@ describe('throwIfMoreThanOneCodegenNativecommands', () => {

describe('throwIfConfigNotfound', () => {
it('throws an error if config is not found', () => {
const configs: Array<{[string]: string}> = [];
const configs: Array<{[key: string]: string}> = [];
expect(() => {
throwIfConfigNotfound(configs);
}).toThrowError('Could not find component config for native component');
});

it('does not throw an error if config contains some elements', () => {
const configs: Array<{[string]: string}> = [
const configs: Array<{[key: string]: string}> = [
{
propsTypeName: 'testPropsTypeName',
componentName: 'testComponentName',
Expand All @@ -1006,7 +1006,7 @@ describe('throwIfConfigNotfound', () => {

describe('throwIfMoreThanOneConfig', () => {
it('throws an error if config is not found', () => {
const configs: Array<{[string]: string}> = [
const configs: Array<{[key: string]: string}> = [
{
propsTypeName: 'testPropsTypeName1',
componentName: 'testComponentName1',
Expand All @@ -1022,7 +1022,7 @@ describe('throwIfMoreThanOneConfig', () => {
});

it('does not throw an error if config contains some elements', () => {
const configs: Array<{[string]: string}> = [
const configs: Array<{[key: string]: string}> = [
{
propsTypeName: 'testPropsTypeName',
componentName: 'testComponentName',
Expand Down
Loading
Loading