Skip to content

TS => MJS. Iteration 4 - #1456

Merged
sergey-shandar merged 5 commits into
mainfrom
fjs/types/function/compare/module.f
Aug 8, 2026
Merged

TS => MJS. Iteration 4#1456
sergey-shandar merged 5 commits into
mainfrom
fjs/types/function/compare/module.f

Conversation

@sergey-shandar

@sergey-shandar sergey-shandar commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

BREAKING CHANGES. Continues the stage-1 TypeScript-to-mjs migration
(#1449) started in #1452/#1453/#1454. Migrates
fjs/types/function/compare from authored TypeScript (.f.ts) to
JSDoc-typed JavaScript (.f.mjs), and updates all importers to the new
specifier.

  • fjs/types/function/compare: same runtime exports (index3, index5,
    cmp, min, max, bsearch) and same types (Sign, Compare<T>,
    Cmp<T>, Cmp1, Cmp2<A, B>), now authored as .f.mjs with JSDoc
    types
  • Importers updated to ./module.f.mjs: fjs/asn.1, fjs/types/bigint,
    fjs/types/bit_vec, fjs/types/btree/{find,remove,set},
    fjs/types/number, fjs/types/ordered_map, fjs/types/range_map,
    fjs/types/sorted_list, fjs/types/sorted_set, fjs/types/string,
    and the compare proof

Any code importing this module by explicit .f.ts path needs to update.

Test plan

  • npm test (tsc + full proof suite): 2354 pass, 0 fail

🤖 Generated with Claude Code

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
functionalscript d002dc1 Commit Preview URL

Branch Preview URL
Aug 08 2026, 08:47 PM

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sergey-shandar sergey-shandar changed the title compare TS => MJS. Iteration 4 Aug 8, 2026

@o2alexanderfedin o2alexanderfedin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 0d28a42f. Clean iteration, and the CHANGELOG entry is there this time.

All five exported types (Sign, Compare, Cmp, Cmp1, Cmp2) were already export type in the .ts, so the typedef-visibility issue from #1453/#1454 doesn't arise here — nothing goes from private to public.

Verified rather than eyeballed:

  • Every type is unchanged under a strict Equal<A,B> check, including the conditional Cmp2<A,B> (Cmp2<number,number>number, Cmp2<string,number>never).
  • The self-referential constraint <A extends Cmp1>(a: A) => <B extends Cmp2<A, B>>(b: B) => … survives translation, which was the part most likely to break. The rejection the docstring promises still happens: min(1)("a"), max(1)("a"), cmp(1)("a"), cmp(1)(2n) all fail with TS2345: … not assignable to parameter of type 'never', and cmp({}) fails against Cmp1.
  • index3 / index5 still return Index<3> / Index<5>index3(...) assigned to 3 correctly errors with Type '0 | 1 | 2' is not assignable to type '3'.
  • npm testpass: 2354, fail: 0, total: 2354; npx tsc clean.

Follow-up: stale .f.ts paths are accumulating across the series

Not from this PR, and not blocking it — but it's now big enough to be worth one sweep. On main, 30 lines across 13 files still reference the old .f.ts path of a module that has already migrated:

AGENTS.md                                   2
fjs/types/object/todo/structurally-same.md  2
fjs/types/ordered_map/todo/at-nullable-map.md 2
… 10 more todo files                        1 each

The two in AGENTS.md are the ones I'd fix first, since agents act on that file:

  • AGENTS.md:205 tells you to import Assert from fjs/asserts/module.f.ts and Equal from fjs/types/ts/module.f.ts. Both are now .f.mjs, so following that snippet literally produces a broken import — and it's exactly the snippet someone copies when writing a type-level proof.
  • AGENTS.md:183 uses fjs/asserts/module.f.ts as its example of an unmigrated helper, which is now the opposite of true — asserts migrated first, in #1452.

Each iteration adds a few more, so a single grep-and-fix pass at the end of stage 1 would probably be cheaper than doing it per-PR. Might be worth a line in the migration todo so it isn't forgotten.

@sergey-shandar

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9076ca8ef1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread CHANGELOG.md
Comment on lines +24 to +26
`fjs/types/function/operator` migrate from authored TypeScript (`.f.ts`) to
JSDoc-typed JavaScript (`.f.mjs`) under the stage-1 TypeScript-to-mjs
migration — importers must use the `.f.mjs` specifier

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fix the stale operator source references

After this rename, a repo-wide search still finds todo/flow.md:241 linking to the deleted fjs/types/function/operator/module.f.ts and fjs/types/function/todo/uncurry-accumulator-types.md:13 directing readers to that old path. Following the canonical todo documentation now produces a broken link or points contributors at a nonexistent source file, so these references should be updated to .f.mjs with the other importers.

AGENTS.md reference: AGENTS.md:L10-L11

Useful? React with 👍 / 👎.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sergey-shandar

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: d002dc1498

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sergey-shandar
sergey-shandar marked this pull request as ready for review August 8, 2026 20:54
@sergey-shandar
sergey-shandar added this pull request to the merge queue Aug 8, 2026
Merged via the queue into main with commit a713e66 Aug 8, 2026
19 checks passed
@sergey-shandar
sergey-shandar deleted the fjs/types/function/compare/module.f branch August 8, 2026 21:07
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