Repository navigation
chore(types): replace explicit any in 20 more files (batch 2) - #45
Merged
Merged
Conversation
Replace every explicit `any` in the next 20 files with real types and drop them from the no-explicit-any warn list in eslint.config.mjs. no-explicit-any warnings: 387 -> 243; files with `any`: 26 -> 6. - Parsed upstream JSON gets small interfaces covering only the fields that are read (RIPEstat, MITRE CVE 5.0, CIRCL, Google DoH, RDAP, isMalicious, OTX, SatNOGS, OpenSky, ip-api, AbuseIPDB, ThreatFox, MalwareBazaar, state DOT camera feeds). - Response builders are typed result interfaces. - Components reuse existing types (NewsItem, EarthquakesPayload, ReconFinding, CctvCamera) and react-force-graph-2d's NodeObject / LinkObject / ForceGraphMethods. - Types only. No eslint-disable, no `as unknown as`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
This is batch 2 of removing explicit
any(batch 1 was #40). It replaces every explicitanyin the 20 files in scope with real types and takes those files off theno-explicit-anywarn list ineslint.config.mjs.Only types change. tsc is clean, and the emitted logic is the same apart from the small cases under Behaviour notes.
anycounts (npx eslint -f json .)no-explicit-anyanyThat is 144 removed. All 20 files in scope are clean, and none were skipped.
Files cleaned (20)
cctv/us-dot-additional.ts,cyber-intel,flights/airport,malware,news,satellites/enrich,scm-suppliers,threat-intelosint/{bgp,cve,dns,ismalicious,otx,whois}CyberIntelPanel,EntityGraphPanel,LayerPanel,LiveAlertslib/feeds/flights.ts,lib/sdk/PolybolosClient.tsStill on the warn list (out of scope for this batch)
cctv/route.ts,maritime/route.ts(skipped on purpose in #40),page.tsx,OsintPanel.tsx,OsirisMap.tsx,lib/feeds/markets.ts.How the
anys were replacedRipeData,MitreCveRecord,CirclCve,DohResponseRdapDomain(jCard entries typed asVCardPropertytuples),IsMaliciousCheck,OtxGeneral/OtxGeo/OtxMalware/OtxUrlListSatnogsTransmitter,IpApiGeo,AbuseEntry,ThreatFoxIoc,MalwareBazaarSampleRawAircraft(readsb field names)OpenSkyState, a positional tuple for indices 0–11otxFetchis now generic (otxFetch<T>), and each call names its section type.results: any = {}filled in step by step) are now typed result interfaces:BgpResult,DnsResult,WhoisResult,IsMaliciousResult,SatEnrichResult,CyberIntelResponse,AirportBoard,ThreatEntry,MalwareThreat.NewsItemandEarthquakesPayload['earthquakes']inLiveAlertsReconFindingfromOsintPanelinCyberIntelPanelCctvCameraand the earthquake type inPolybolosClientLucideIconfor the tab iconsEntityGraphPaneluses react-force-graph-2d's exportedNodeObject,LinkObjectandForceGraphMethods:propertiesis nowRecord<string, unknown>;URLSearchParams.setcalls wrap the value inString(...). The runtime result is the same becausesetalready converts its value to a string.paintLinkreadslink.source/link.targetas NodeObject, with a comment: force-graph has already swapped the ids for node objects by the time it paints.s.y!/t.y!follow the file's existingn.x!/n.y!style.LayerPanel:dataisRecord<string, unknown>. Rows are narrowed withArray.isArraythrough a localrowsvariable.LayerDef/LayerGroup.setActiveLayersis typed as(update: <L extends ActiveLayers>(prev: L) => L) => void. With this type the page can pass itsuseStatesetter for its concrete layer-flag object without a cast. A plainDispatch<SetStateAction<Record<string, boolean>>>would not accept that setter.lib/feeds/flights.ts:FlightsPayloadnow usesFlight(the return type ofclassifyFlight) andJammingZoneinstead ofany[].PolybolosClient:ingestOsirisDatatakes anOsirisFeedDatainterface, with one input shape per feed. The position fields use the typesPolybolosEntity['position']expects. This method has no callers in the repo. If it is later fedFlightsPayloaddirectly,speed_knots(number | nullin the feed) will need?? undefined.cyber-intel:cve.summary?.length > 200andcve.capec?.length > 0becamecve.summary && cve.summary.length > 200andcve.capec && cve.capec.length > 0. Both give the same result for every input, and no!is needed. The MITRE block is first built as a typedmitreEnrichmentconst, then assigned toresponse, somitre_nodescan read it without narrowing.eslint-disable, noas unknown as, no newany. The single-cast[] as DohAnswer[](an empty-array literal) follows the existing[] as string[]idiom.Behaviour notes (tiny, called out explicitly)
osint/bgpcatch:detailis nowString(e)instead ofundefinedwhen something other than anErroris thrown. This is the same pattern as batch 1.EntityGraphPanel:graphRefnow starts asundefinedinstead ofnull. React-force-graph's ref type isMutableRefObject<ForceGraphMethods | undefined>, so anullstart does not type-check against it. The component never reads the ref, and the library fills it in on mount.CyberIntelPanelrecon findings:onLocate(f.lat, f.lng!). The check guardslat, and the only producer (OsintPanel) always setslatandlngtogether. The runtime call is unchanged.The ratchet (
eslint.config.mjs)export const x: any = 1;to the cleanedsrc/lib/feeds/flights.tsgiveserror Unexpected any.Test plan
npx tsc --noEmit: 0 errorsnpx eslint .: 0 errors (254 warnings, down from 398;no-explicit-any387 → 243)npx vitest run(excluding the cache/rateLimit/feedStore/postgres suites): 6 files, 66 tests passnpm run build: succeedsorigin/main;LayerPanel.tsx, and the mostly-CRLFosint/{cve,dns,whois}) keep their layout, with new lines matching the surrounding endings;next start -p 3014:origin/mainwas built separately and served on port 3015. 22 requests over every touched route (plus/api/flightsand/api/cctv) returned the same status codes on both builds:timestampstripped matched forosint/cve,osint/dns,osint/bgpand the airport 404.🤖 Generated with Claude Code