Use record utility type in a few places (#3290)

* Replace object syntax with Record utility

* Replace interface with Record utility

I did not know how to be DRY here.
This commit is contained in:
Johannes Klein
2025-12-12 23:33:09 +01:00
committed by GitHub
parent f7ee3fb829
commit beee0b64ab
5 changed files with 16 additions and 19 deletions

View File

@@ -15,9 +15,7 @@ interface Props {
isDarkModeEnabled?: boolean;
}
type Aliases = {
[key: string]: string;
};
type Aliases = Record<string, string>;
// Most of these are names for these icons used in design mapped to more
// consistent and deduped filenames. We might also put aliases of convenience
// here, e.g. "speech" and "chat" might both map to "comments" if we find

View File

@@ -81,10 +81,11 @@ export function getMapRegion( totalBounds: MapBoundaries ): Region {
};
}
interface Params {
[key: string]: unknown;
}
export async function fetchObservationUUID( currentZoom: number, latLng: LatLng, params: Params ) {
export async function fetchObservationUUID(
currentZoom: number,
latLng: LatLng,
params: Record<string, unknown>
) {
const UTFPosition = createUTFPosition( currentZoom, latLng.latitude, latLng.longitude );
const {
mTilePositionX,
@@ -92,7 +93,7 @@ export async function fetchObservationUUID( currentZoom: number, latLng: LatLng,
mPixelPositionX,
mPixelPositionY
} = UTFPosition;
const tilesParams: Params = {
const tilesParams: Record<string, unknown> = {
...params,
style: "geotilegrid"
};

View File

@@ -15,15 +15,13 @@ interface Props {
headerText: string;
insideModal?: boolean;
onPressClose?: ( ) => void;
radioValues: {
[key: string]: {
value: string;
icon?: string;
label: string;
text?: string;
buttonText?: string;
};
};
radioValues: Record<string, {
value: string;
icon?: string;
label: string;
text?: string;
buttonText?: string;
}>;
selectedValue?: string;
testID?: string;
topDescriptionText?: React.JSX.Element;

View File

@@ -68,7 +68,7 @@ const ALLOWED_ATTRIBUTES_NAMES = (
"href src width height alt cite title class name abbr value align target rel"
).split( " " );
const ALLOWED_ATTRIBUTES: { [key: string]: string[] } = { a: ["href"] };
const ALLOWED_ATTRIBUTES: Record<string, string[]> = { a: ["href"] };
ALLOWED_TAGS.filter( tag => tag !== "a" )
.forEach( tag => { ALLOWED_ATTRIBUTES[tag] = ALLOWED_ATTRIBUTES_NAMES; } );

View File

@@ -4,7 +4,7 @@
interface UTFGrid {
grid: string[];
keys: string[];
data?: { [key: string]: unknown };
data?: Record<string, unknown>;
}
const EXPANSION_PIXELS = 16;