Skip to content

TS => MJS. Iteration 2 - #1453

Merged
sergey-shandar merged 4 commits into
mainfrom
fjs/types/function
Aug 8, 2026
Merged

TS => MJS. Iteration 2#1453
sergey-shandar merged 4 commits into
mainfrom
fjs/types/function

Conversation

@sergey-shandar

Copy link
Copy Markdown
Contributor

No description provided.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 7, 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 15c90ec Commit Preview URL

Branch Preview URL
Aug 08 2026, 12:21 AM

@sergey-shandar
sergey-shandar marked this pull request as draft August 7, 2026 21:34

@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 acb29736. Three modules converted — types/function, types/nullable, types/option — plus ~45 mechanical import rewrites. The generics here are much richer than #1452's asserts, so I checked that the JSDoc @type annotations are actually enforced rather than silently collapsing to any, which is the failure mode that would keep the suite green while deleting the type safety.

Contracts hold. A probe exercising compose / identity / flip / fn / map / unwrap / fromUndefined / mapUnwrap compiles clean, and six deliberately-wrong uses each produce the correct specific error:

mutation diagnostic
identity(1) as string TS2322 numberstring
compose(g)((s: number) => s) TS2345 not assignable to Func<string, number>
unwrap(…) as string TS2322 numberstring
fn(g).map(…).result('nope') TS2345 stringnumber
flip(…)(1) TS2345 numberstring
map(…)(…) as number TS2322 Nullable<string>number

Func<string, number> and Nullable<string> appearing in those messages is the useful part — the typedefs resolve, they aren't any. compose's two separate generic scopes survive too: compose(g) stays generic in O and instantiates independently at each call.

npm testpass: 2354, fail: 0, total: 2354, identical to main. npx tsc clean.

One observation: Fn changes from private to public

In the old module.f.ts, Fn was deliberately declared without export:

type Fn<I, O> = { ... }        // no export

A JSDoc @typedef in a module is exported whether you want it or not, so it's now importable. Confirmed in both directions:

  • on main: import type { Fn } from './module.f.ts'TS2724: '"./module.f.ts"' has no exported member named 'Fn'
  • on this branch: the same import against module.f.mjs compiles clean

I also tried /** @private */ on the typedef to see whether the old visibility could be preserved — it does not suppress the export, so there's no cheap fix; the alternatives are to accept the widening or restructure.

Not blocking, and arguably harmless: Fn is only referenced inside its own module, and it's a benign utility type. But #1449's plan sets the bar at "translate without changing the public type contract", and this is a real (if small) contract change in the widening direction, so it seems worth a conscious decision rather than passing unnoticed — especially since the same thing will recur for every unexported type the migration touches. Might be worth one line in the migration doc stating that unexported type aliases become public and that's accepted.

@sergey-shandar
sergey-shandar marked this pull request as ready for review August 8, 2026 00:32
@sergey-shandar
sergey-shandar added this pull request to the merge queue Aug 8, 2026
Merged via the queue into main with commit a3c7a5d Aug 8, 2026
19 checks passed
@sergey-shandar sergey-shandar mentioned this pull request Aug 8, 2026
2 tasks
@sergey-shandar
sergey-shandar deleted the fjs/types/function branch August 8, 2026 00:36
@sergey-shandar sergey-shandar mentioned this pull request Aug 8, 2026
1 task
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