From 5027dfbff7b54be43a398ca374f1b59105efef03 Mon Sep 17 00:00:00 2001 From: Epi Lo Date: Tue, 21 Apr 2026 14:36:45 +0800 Subject: [PATCH] Type renameProperties generically to eliminate implicit `any` in utils (toward #133) Scope: src/utils/index.ts only. Under `tsc --noImplicitAny --strictNullChecks`, both parameters of `renameProperties` were implicitly typed as `any`. Introduce a `FeatureWithBegin` local type capturing the only shape assumption the function makes about its input (an optional `begin` field of type string or number). The function is then made generic in `T extends FeatureWithBegin`, which preserves every other property of the caller's feature shape on the returned objects. Runtime behaviour is unchanged; this is purely a type-level refactor. --- src/utils/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index ba08323..a7482a3 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,4 +1,8 @@ -export const renameProperties = (features) => +type FeatureWithBegin = { begin?: string | number }; + +export const renameProperties = ( + features: T[] +): Array => features.map((ft) => ({ ...ft, start: ft.begin || undefined,