Skip to content

fix(fetchium): keep Date as Date in ExtractType - #84

Merged
jimmy-phantom merged 1 commit into
mainfrom
martin/extract-type-date
Nov 1, 2026
Merged

jimmy-phantom merged 1 commit into
mainfrom
martin/extract-type-date

Conversation

@marty-mcflai

Copy link
Copy Markdown
Contributor

Summary

  • ExtractType stops at Date — it used to recurse into Date because Date extends object, rebuilding it as a mapped type.
  • Why it broke — the function branch infers one overload per method, so the rebuilt type isn't assignable to Date. Every t.format('date-time') / t.format('date') field hit this, and consumers had to add structural { getTime(): number } shims (e.g. phantom/wallet#34774).
  • Tests — format.test.ts type-inference cases now assign the extracted type to Date. Before, they only checked Date → extracted type, which passed even with the bug.

What changed

%%{init: {"theme":"base","themeVariables":{"primaryColor":"#eef2f7","primaryTextColor":"#0f172a","primaryBorderColor":"#94a3b8","secondaryColor":"#e2e8f0","secondaryTextColor":"#0f172a","tertiaryColor":"#f8fafc","tertiaryTextColor":"#0f172a","textColor":"#0f172a","lineColor":"#64748b","edgeLabelBackground":"#e2e8f0","clusterBkg":"#f8fafc","clusterBorder":"#cbd5e1","titleColor":"#0f172a"}}}%%
flowchart LR
  classDef changed fill:#d4f4dd,stroke:#2d7d46,stroke-width:2px,color:#0f172a;

  Format["t.format('date-time')<br/>TypeDef&lt;Date&gt;"] --> Unwrap[ExtractType unwraps TypeDef]
  Unwrap --> DateCheck{"T extends Date?<br/>NEW"}
  DateCheck -->|yes| Date[Date]
  DateCheck -->|no| Obj[object → mapped type]
  class DateCheck changed
Loading

Testing

  • Not run locally. Covered by check-types (the type assertions in format.test.ts).

🤖 Generated with Claude Code

ExtractType recursed into Date because Date extends object, rebuilding it as a
mapped type whose overloaded methods lost signatures, so t.format('date-time')
fields weren't assignable to Date.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@marty-mcflai
marty-mcflai marked this pull request as ready for review October 21, 2026 07:50
@marty-mcflai
marty-mcflai requested review from a team and pzuraq as code owners October 21, 2026 07:50
@jimmy-phantom
jimmy-phantom merged commit b00c6d5 into main Nov 1, 2026
1 check passed
@jimmy-phantom
jimmy-phantom deleted the martin/extract-type-date branch November 1, 2026 04:04
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.

2 participants