Skip to content

Commit 797d148

Browse files
chore: remove unsafe any casts
Removes unsafe casts in tab test ID handling and theme color lookup.
1 parent c497e4b commit 797d148

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

app/(tabs)/_layout.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,14 @@ function CustomTabBar(props: BottomTabBarProps) {
119119
accessibilityRole="button"
120120
accessibilityState={isFocused ? { selected: true } : {}}
121121
accessibilityLabel={options.tabBarAccessibilityLabel}
122-
testID={(options as any).tabBarButtonTestID}
122+
testID={(() => {
123+
const o = options as unknown as {
124+
tabBarButtonTestID?: unknown;
125+
};
126+
return typeof o.tabBarButtonTestID === "string"
127+
? o.tabBarButtonTestID
128+
: undefined;
129+
})()}
123130
onPress={onPress}
124131
onLongPress={onLongPress}
125132
style={{

context/ColorPaletteContext.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
HabitColorConfig,
1616
isThemeReference,
1717
PriorityLevel,
18+
ThemeColorKey,
1819
} from "@/types/colors";
1920
import AsyncStorage from "@react-native-async-storage/async-storage";
2021
import React, {
@@ -131,8 +132,9 @@ export function ColorPaletteProvider({ children }: { children: ReactNode }) {
131132
(colorValue: ColorValue): string => {
132133
if (isThemeReference(colorValue)) {
133134
const key = getThemeColorKey(colorValue);
134-
if (key && key in theme.colors) {
135-
return (theme.colors as any)[key] || colorValue;
135+
if (key) {
136+
const colors = theme.colors as Record<ThemeColorKey, string>;
137+
return colors[key] ?? colorValue;
136138
}
137139
}
138140
return colorValue;

0 commit comments

Comments
 (0)