Skip to content

Commit 90cc273

Browse files
committed
Fix Twoslash polyfill mismatches in new 2.2 docs
Since PR #768 made Fedify's generated `.d.ts` resolve `Temporal` through the ambient `lib.esnext.temporal` namespace, Twoslash blocks that import `Temporal` from `@js-temporal/polyfill` and then construct a Fedify vocab object fail with TS2322 ("until(...).sign" mismatch). Merging 2.1.13 into 2.2-maintenance surfaced four docs added on the 2.2 line where this happens. The rule depends on whether the polyfill import is visible to readers: - Hidden by `---cut-before---` / `---cut---` (type-check-only context): drop the line. The ambient `Temporal` from `lib.esnext.temporal` then resolves the references, leaving the rendered output untouched. Done in `docs/manual/migrate.md`, `docs/manual/pragmatics.md`, and two cut-prefixed blocks in `docs/tutorial/content-sharing.md`. - Visible to the reader (no cut directive): the tutorial still needs that line so Node 22-25 readers know to install the polyfill, so keep the import and add `2322` to the block's `// @Noerrors:` directive instead. Done in two `docs/tutorial/content-sharing.md` blocks (the `server/federation.ts` "imports to add" snippet and the `comments.post.ts` example). `astro-blog.md` and `microblog.md` already shield their polyfill imports with `// @noErrors` wildcards or plain `typescript` fences, so they don't need changes. `vitepress build` completes locally without errors. #767 Assisted-by: Claude Code:claude-opus-4-7
1 parent 4e8c673 commit 90cc273

3 files changed

Lines changed: 2 additions & 10 deletions

File tree

docs/manual/migrate.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,8 +1787,6 @@ console.log(doc);
17871787
With `@fedify/vocab`:
17881788

17891789
~~~~ typescript twoslash
1790-
import { Temporal } from "@js-temporal/polyfill";
1791-
// ---cut-before---
17921790
import { Create, Note } from "@fedify/vocab";
17931791

17941792
const create = new Create({
@@ -1942,8 +1940,6 @@ AS2 document for processing. Drop-in replacement for the idiomatic
19421940
`activitystrea.ms` usage in most JSON-LD bridges:
19431941

19441942
~~~~ typescript twoslash
1945-
import { Temporal } from "@js-temporal/polyfill";
1946-
// ---cut-before---
19471943
import { Activity, Create, Note } from "@fedify/vocab";
19481944

19491945
async function buildOutbound(

docs/manual/pragmatics.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,6 @@ below the choices.
549549

550550
~~~~ typescript twoslash
551551
import { Collection, Note, Question } from "@fedify/vocab";
552-
import { Temporal } from "@js-temporal/polyfill";
553552
// ---cut-before---
554553
new Question({
555554
content: "<p>Which pragmatics example should the manual explain first?</p>", // [!code highlight]
@@ -587,7 +586,6 @@ Use `inclusiveOptions` for polls where a voter may choose more than one option.
587586

588587
~~~~ typescript twoslash
589588
import { Collection, Note, Question } from "@fedify/vocab";
590-
import { Temporal } from "@js-temporal/polyfill";
591589
// ---cut-before---
592590
new Question({
593591
content: "<p>Which pragmatics details should the manual cover next?</p>", // [!code highlight]

docs/tutorial/content-sharing.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3465,7 +3465,7 @@ Open *server/federation.ts*. Add `Document`, `Note`, and
34653465
`Temporal` polyfill, and add `posts` to the schema import:
34663466

34673467
~~~~ typescript twoslash [server/federation.ts]
3468-
// @noErrors: 2304 2307
3468+
// @noErrors: 2304 2307 2322
34693469
import {
34703470
Accept,
34713471
Document,
@@ -3506,7 +3506,6 @@ Then add a final dispatcher block after the followers dispatcher:
35063506
// @noErrors: 2304 2307 7006
35073507
import { type Federation } from "@fedify/fedify";
35083508
import { Document, Note, PUBLIC_COLLECTION } from "@fedify/vocab";
3509-
import { Temporal } from "@js-temporal/polyfill";
35103509
import { and, eq } from "drizzle-orm";
35113510
import { db } from "./db/client";
35123511
import { posts, users } from "./db/schema";
@@ -6516,7 +6515,7 @@ and ends in the textarea form. Append it inside the existing
65166515
Create *server/api/comments.post.ts*:
65176516

65186517
~~~~ typescript twoslash [server/api/comments.post.ts]
6519-
// @noErrors: 2304 2307
6518+
// @noErrors: 2304 2307 2322
65206519
import {
65216520
Create,
65226521
getActorHandle,
@@ -6706,7 +6705,6 @@ import {
67066705
MemoryKvStore,
67076706
} from "@fedify/fedify";
67086707
import { Mention, Note, PUBLIC_COLLECTION } from "@fedify/vocab";
6709-
import { Temporal } from "@js-temporal/polyfill";
67106708
import { and, eq } from "drizzle-orm";
67116709
import { db } from "./db/client";
67126710
import { comments, posts, users } from "./db/schema";

0 commit comments

Comments
 (0)