Skip to content

fix(types): correct TypeScript type declarations to match runtime shapes#7

Closed
dmchaledev wants to merge 1 commit into
mainfrom
fix/typescript-type-declarations
Closed

fix(types): correct TypeScript type declarations to match runtime shapes#7
dmchaledev wants to merge 1 commit into
mainfrom
fix/typescript-type-declarations

Conversation

@dmchaledev

Copy link
Copy Markdown
Contributor

Summary

Fixes the index.d.ts type declarations for @hailbytes/vulnerability-calculator so they accurately reflect the runtime objects returned by calculate().

What was wrong

The previous type declarations had several mismatches with the actual runtime shapes:

Issue Old (incorrect) New (correct)
VMResources fields cpu, ram, storage cpu_cores, ram_gb, ram_recommended, storage_gb
Missing VMResources fields network_bandwidth_mbps, docker_required, tool_type, scaling_info
VulnInputs missing field scan_window: number
VulnResult.timing Record<string, unknown> Proper ScanTiming interface
VulnResult.costs Record<string, unknown> Proper Costs interface
Missing interfaces ScanTiming, ToolBreakdownItem, ROIAnalysis, Costs

What was changed

  • Rewrote index.d.ts with accurate interfaces matching the actual runtime output of calculate()
  • All existing tests continue to pass (6/6 ✅)
  • No runtime code changes — this is a type-only fix

Impact

TypeScript consumers importing @hailbytes/vulnerability-calculator will now get:

  • Accurate type checking on calculate() return values
  • Proper IDE autocompletion for vm_resources.*, timing.*, costs.*
  • Correct optional/required field detection

Fixes the index.d.ts type declarations for the @hailbytes/vulnerability-calculator package.

Previously, the declared types did not match the actual runtime objects:
- VMResources declared cpu/ram/storage, but runtime uses cpu_cores/ram_gb/ram_recommended/storage_gb
- Missing fields: network_bandwidth_mbps, docker_required, tool_type, scaling_info
- VulnResult.timing and .costs were typed as Record<string, unknown> instead of proper interfaces
- Missing interfaces: ScanTiming, ToolBreakdownItem, ROIAnalysis, Costs
- VulnInputs was missing the required scan_window field
- VulnInputs.scan_window is number, not string

This fix adds proper interfaces for all runtime shapes exported by calculate(),
enabling TypeScript consumers to get accurate type checking and IDE autocompletion.
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