Type renameProperties generically to eliminate implicit any in utils (toward #133)#139
Open
Epi-1120 wants to merge 1 commit intoebi-webcomponents:mainfrom
Open
Type renameProperties generically to eliminate implicit any in utils (toward #133)#139Epi-1120 wants to merge 1 commit intoebi-webcomponents:mainfrom
any in utils (toward #133)#139Epi-1120 wants to merge 1 commit intoebi-webcomponents:mainfrom
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Incremental step toward #133 — eliminate implicit and explicit
anyfromsrc/. Continuing the small-PR approach from #138, this PR narrows the scope tosrc/utils/index.tsonly.Under
tsc --noImplicitAny --strictNullChecks, both parameters ofrenamePropertieswere implicitly typed asany:What this PR does
FeatureWithBegintype capturing the only shape assumption the function body actually makes about its input (an optionalbeginfield of typestring | number).renamePropertiesgeneric inT 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
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.tsconfig.json/ ESLint config yet.Verification
Follow-ups (separate PRs)
src/adapters/**implicit-any cleanup (largest cluster)src/tooltips/**implicit-any cleanupsrc/protvista-uniprot.ts— the central adapter dispatch map (Record<string, (...args: any[]) => any>) and theNightingaleEventdetail shapenoImplicitAny: true,strictNullChecks: true, and@typescript-eslint/no-explicit-any: 'error'once the tree is cleanTesting checklist
vite build,vitest run)