Skip to content

Commit abe44fc

Browse files
build(types): fix a few type errors (#7834)
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. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Philippe Serhal <[email protected]>
1 parent ed232eb commit abe44fc

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/lib/geo-location.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ const getGeoLocationFromAPI = async (): Promise<Geolocation> => {
9797
method: 'GET',
9898
signal: AbortSignal.timeout(REQUEST_TIMEOUT),
9999
})
100-
// @ts-expect-error TS(2339) - Property 'geo' does not exist on type 'unknown'
101-
const { geo } = await res.json()
100+
const { geo } = (await res.json()) as { geo: Geolocation }
102101

103102
return geo
104103
}

src/lib/string.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
// @ts-expect-error TS(7006) FIXME: Parameter 't' implicitly has an 'any' type.
2-
export const capitalize = function (t) {
3-
// @ts-expect-error TS(7006) FIXME: Parameter 'string' implicitly has an 'any' type.
4-
return t.replace(/(^\w|\s\w)/g, (string) => string.toUpperCase())
5-
}
1+
export const capitalize = (t: string): string => t.replace(/(^\w|\s\w)/g, (match) => match.toUpperCase())

0 commit comments

Comments
 (0)