From 2358f74d6469088ec7f0cf09cadef3a14cbdf80a Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 31 Dec 2025 16:07:22 +0000 Subject: [PATCH] feat: Improve type safety in leaf-node modules This commit improves type safety in two leaf-node modules by removing `@ts-expect-error` and implicit `any` types. In `src/lib/string.ts`, the `capitalize` function was updated to use explicit `string` types for its parameters, eliminating the implicit `any` types. In `src/lib/geo-location.ts`, the `@ts-expect-error` in the `getGeoLocationFromAPI` function was removed by adding a type assertion to the `res.json()` call, ensuring the `geo` property is correctly typed. --- src/lib/geo-location.ts | 3 +-- src/lib/string.ts | 6 +----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/lib/geo-location.ts b/src/lib/geo-location.ts index 49ff1878cb4..875925ec544 100644 --- a/src/lib/geo-location.ts +++ b/src/lib/geo-location.ts @@ -97,8 +97,7 @@ const getGeoLocationFromAPI = async (): Promise => { method: 'GET', signal: AbortSignal.timeout(REQUEST_TIMEOUT), }) - // @ts-expect-error TS(2339) - Property 'geo' does not exist on type 'unknown' - const { geo } = await res.json() + const { geo } = (await res.json()) as { geo: Geolocation } return geo } diff --git a/src/lib/string.ts b/src/lib/string.ts index 9504733a69c..d7cbed34c50 100644 --- a/src/lib/string.ts +++ b/src/lib/string.ts @@ -1,5 +1 @@ -// @ts-expect-error TS(7006) FIXME: Parameter 't' implicitly has an 'any' type. -export const capitalize = function (t) { - // @ts-expect-error TS(7006) FIXME: Parameter 'string' implicitly has an 'any' type. - return t.replace(/(^\w|\s\w)/g, (string) => string.toUpperCase()) -} +export const capitalize = (t: string): string => t.replace(/(^\w|\s\w)/g, (match) => match.toUpperCase())