Skip to content

Type renameProperties generically to eliminate implicit any in utils (toward #133)#139

Open
Epi-1120 wants to merge 1 commit intoebi-webcomponents:mainfrom
Epi-1120:refactor/utils-no-implicit-any
Open

Type renameProperties generically to eliminate implicit any in utils (toward #133)#139
Epi-1120 wants to merge 1 commit intoebi-webcomponents:mainfrom
Epi-1120:refactor/utils-no-implicit-any

Conversation

@Epi-1120
Copy link
Copy Markdown

Purpose

Incremental step toward #133 — eliminate implicit and explicit any from src/. Continuing the small-PR approach from #138, this PR narrows the scope to src/utils/index.ts only.

Under tsc --noImplicitAny --strictNullChecks, both parameters of renameProperties were implicitly typed as any:

src/utils/index.ts(1,34): error TS7006: Parameter 'features' implicitly has an 'any' type.
src/utils/index.ts(2,17): error TS7006: Parameter 'ft' implicitly has an 'any' type.

What this PR does

  • Introduces a local FeatureWithBegin type capturing the only shape assumption the function body actually makes about its input (an optional begin field of type string | number).
  • Makes renameProperties generic in T extends FeatureWithBegin, so every other property on the caller's feature shape is preserved on the returned objects. No downstream type information is lost.

What this PR does not do

  • No runtime changes. The function body is byte-for-byte identical.
  • No changes to callers (src/adapters/feature-adapter.ts, src/adapters/proteomics-adapter.ts). Both still pass untyped data in for now; that is left to a follow-up PR that tightens the adapters themselves.
  • No changes to tsconfig.json / ESLint config yet.

Verification

tsc --noImplicitAny --strictNullChecks   # src/utils: 0 errors (was 2)
eslint src/utils/index.ts                # clean
vite build                               # OK
vitest run                               # 4 files / 60 tests, all pass

Follow-ups (separate PRs)

  • src/adapters/** implicit-any cleanup (largest cluster)
  • src/tooltips/** implicit-any cleanup
  • src/protvista-uniprot.ts — the central adapter dispatch map (Record<string, (...args: any[]) => any>) and the NightingaleEvent detail shape
  • Closing PR: enable noImplicitAny: true, strictNullChecks: true, and @typescript-eslint/no-explicit-any: 'error' once the tree is clean

Testing checklist

  • I have tested the changes locally (vite build, vitest run)
  • The change has no runtime impact (types only)
  • The diff is minimal and scoped to a single file

…s (toward ebi-webcomponents#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant