Repository navigation
fix(types): correct shipped locals.d.ts EmDashHandlers path - #1077
Conversation
Closes #1053. Two parts: 1. wordpress-plugin.ts: the analyze-endpoint error body from response.json() is unknown under @cloudflare/workers-types; narrow it before reading .message (was the reported TS18046). The other reported error (byline.ts kysely Transaction variance) was TS5.x behaviour, resolved by the TS6 upgrade in #1074. 2. Stop shipping raw .ts for the source-exported subpaths (emdash/routes/*, emdash/api/route-utils, emdash/api/schemas, emdash/auth/providers/*). They are compiled to dist (.mjs + .d.mts), so a strict consumer's tsc only ever sees declarations (skipLibCheck covers them), eliminating the dual-package Database identity wall that is #1053's root cause. ./ui and .astro stay source (the consumer's Astro build must process them). - tsdown: route entrypoints fed via inputOptions.input (literal object, not entry globs -- [param] dirs are glob char-classes). entryFileNames + resolveRoute share one routeArtifactName() so rolldown's reserved [name]/[hash] placeholders cannot mangle dynamic-route artifacts. - A fast static guard (scripts/typecheck-public-source.mjs, wired into CI) fails if any subpath export ships raw .ts/.tsx again. Verified: pnpm build, pnpm typecheck, demos+templates typecheck, demo build (route injection e2e), lint baseline unchanged.
🦋 Changeset detectedLatest commit: 54613d6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-perf-coordinator | 54613d6 | May 17 2026, 12:03 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-i18n | 54613d6 | May 17 2026, 12:04 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-cache | 54613d6 | May 17 2026, 12:05 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-playground | 54613d6 | May 17 2026, 12:06 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
docs | 54613d6 | May 17 2026, 12:04 PM |
|
/review |
There was a problem hiding this comment.
Pull request overview
Fixes a shipped type-declaration regression where emdash/locals imported EmDashHandlers from a non-emitted build artifact, causing Astro.locals.emdash to silently become any in consumer projects. Also resolves the one newly-unmasked type mismatch in the ATProto auth provider by aligning with an existing core casting precedent.
Changes:
- Update
packages/core/locals.d.tsto importEmDashHandlersfrom the actual emitted./dist/astro/types.d.mtsartifact. - Fix
@emdash-cms/auth-atproto’screateKyselyAdapter()call site by castingemdash.dbtoKysely<AuthTables>(matching the established cast pattern in core). - Add a changeset documenting the consumer-facing typing fix for
Astro.locals.emdash.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/core/locals.d.ts |
Corrects the EmDashHandlers import path so locals.emdash no longer degrades to any. |
packages/auth-atproto/src/routes/callback.ts |
Applies the same Kysely<AuthTables> cast pattern used in core to satisfy createKyselyAdapter’s expected DB type. |
.changeset/locals-emdash-typing.md |
Adds a patch changeset describing the restored Astro.locals.emdash typing for consumers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The PR adds two The new line in callback.ts uses: The cleanup.ts line 73 precedent text: Identical. Good. One more thing — the description claims this is "stacked on #1076". Let me check that the base branch is correct and won't accidentally merge unrelated code: The PR base is Summary of reviewThe PR is correct, narrowly-scoped, and well-justified:
No bugs to file. One minor observation worth raising: there's no regression test guarding the import path, and the bug is exactly the kind that would re-occur if entries get reshuffled in Given there are no actual issues with the code changes, this is LGTM territory. LGTM! |
…dle them Compiling the route/admin entries made tsdown try to bundle deps it could not resolve at build time -- 'emdash' (the package importing itself) and '@cloudflare/kumo' (admin-only, not an emdash dep). CI escalates tsdown's bundling advisory to a fatal error. - Externalize 'emdash' (self): compiled routes import it; resolved at the consumer's runtime where the package is installed. - Externalize @aws-sdk/* (optional S3 deps, runtime-only). - Keep the *-admin.tsx providers as source (bridge the admin React + @cloudflare/kumo runtime, like .astro/./ui); revert their exports. - inlineOnly: false -- nothing is unintentionally bundled (all deps external, only our own src is); silences the CI-escalated advisory. Guard's allowlist generalized to RUNTIME_COUPLED (Astro + admin React).
a11fda7 to
50322ba
Compare
resolveRoute resolves emdash/routes/* to the compiled dist artifact with routeArtifactName applied ([ ] -> _), so the media catch-all route's entrypoint is api/media/file/_...key_ not [...key].ts. The catch-all pattern assertion (the actual guarantee) is unchanged.
locals.d.ts imported EmDashHandlers from ./dist/types.d.mts, a path tsdown never emits (it is ./dist/astro/types.d.mts). The augmentation silently resolved to nothing, so Astro.locals.emdash was `any` for every consumer. Point it at the real artifact. This un-masks one real, previously-hidden mismatch: auth-atproto's callback.ts passed Kysely<Database> to createKyselyAdapter (expects Kysely<AuthTables>). Fixed with the canonical cast already used in core's cleanup.ts (Database uses Generated<> wrappers that confuse structural checks; the adapter casts internally; safe at runtime). Stacked on the compile-subpaths change (#1076): with routes compiled, fixing locals only surfaces this single bounded mismatch rather than the dual-package wall. Verified: pnpm typecheck, demos+templates typecheck, lint baseline unchanged, public-source guard.
50322ba to
0d718d0
Compare
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/blocks
@emdash-cms/cloudflare
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
What does this PR do?
Stacked on #1076 (compile source-exported subpaths). Merge #1076 first.
packages/core/locals.d.tsimportedEmDashHandlersfrom./dist/types.d.mts— a path tsdown never emits (the artifact is./dist/astro/types.d.mts). TheApp.Localsaugmentation therefore resolvedEmDashHandlersto nothing andAstro.locals.emdashsilently degraded toanyfor every EmDash site, losing autocomplete and type-checking on the handlers API in consumers' pages/endpoints. This points the import at the real artifact.Correcting it un-masks exactly one previously-hidden real mismatch (it was hidden because
emdashwasany):@emdash-cms/auth-atproto'scallback.tspassedKysely<Database>intocreateKyselyAdapter(which expectsKysely<AuthTables>). Fixed with the canonical cast already used in core'scleanup.ts—Databasecontains the auth tables but usesGenerated<>wrappers that confuse structural checks againstAuthTables, and the adapter casts internally anyway; safe at runtime. Same comment +eslint-disabletext as the existing precedent.Why stacked on #1076: with the route subpaths still shipped as raw source, fixing this path reintroduces the full dual-package
Databasewall (~100 errors). With #1076's routes compiled, fixing it surfaces only this single bounded mismatch.The shipped contract stays
emdash: EmDashHandlers(required) — unchanged for consumers; only the broken import path is corrected.Verified green:
pnpm typecheck, demos + templates typecheck, lint at the existing baseline (adds 0),pnpm format, public-source guard.Type of change
Checklist
pnpm typecheckpassespnpm lintpasses (PR adds 0 diagnostics; repo baseline unchanged)pnpm testpasses (or targeted tests for my change) — verified via full typecheck + demos/templates; no runtime behaviour change (type-declaration + a type-only cast matching existing precedent)pnpm formathas been runpnpm typecheckis the regression signal)emdashpatchAI-generated code disclosure