Repository navigation
Conversation
) Closes #1053. - wordpress-plugin.ts: the analyze-endpoint error body from response.json() is unknown under @cloudflare/workers-types; narrow it before reading .message instead of accessing it on unknown (TS18046). Runtime behaviour unchanged. (#1053 error 1, the kysely Transaction variance, was a TS5.x behaviour resolved by the TS6 upgrade in the base PR.) - Add the public-source typecheck harness: fixtures/public-types reproduces the strict-consumer view (real tsc, @cloudflare/workers-types, emdash/locals) over every .ts/.tsx source-exported subpath; scripts/typecheck-public-source.mjs compares per-(file,code) diagnostic counts to a committed baseline, with hard sanity gates and a hardcoded #1053 sentinel. Wired into the CI typecheck job. - The 23 baseline groups are pre-existing strict-consumer debt, tracked separately; the harness fails on any growth or new shipped-source error.
🦋 Changeset detectedLatest commit: 40a5541 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 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 | 40a5541 | May 17 2026, 08:24 AM |
PR template validation failedPlease fix the following issues by editing your PR description:
See CONTRIBUTING.md for the full contribution policy. |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-i18n | 40a5541 | May 17 2026, 08:25 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
docs | 40a5541 | May 17 2026, 08:25 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-cache | 40a5541 | May 17 2026, 08:26 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-playground | 40a5541 | May 17 2026, 08:26 AM |
@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: |
| const baseDir = resolve(coreDir, dirname(target).replace(WILDCARD_SUFFIX, "")); | ||
| for (const abs of globSync("**/*.{ts,tsx}", { cwd: baseDir })) { | ||
| const rel = abs.replaceAll("\\", "/"); | ||
| specifiers.push(toSpecifier(key.replace("*", rel))); |
|
|
||
| // #1053 sentinel: independent of the baseline file. | ||
| if (counts[SENTINEL_KEY]) { | ||
| fail(`issue #1053 regressed -- ${SENTINEL_KEY.replace("\t", " ")} reappeared in shipped source.`); |
| .filter(([key, n]) => n > (baseline[key] ?? 0)) | ||
| .map( | ||
| ([key, n]) => | ||
| `${key.replace("\t", " ")} (now ${String(n)}, baseline ${String(baseline[key] ?? 0)})`, |
There was a problem hiding this comment.
Pull request overview
This PR fixes a strict-consumer TypeScript error in the WordPress-plugin import source and adds a new CI harness to typecheck all source-exported emdash/* subpaths (which ship raw .ts/.tsx and are not covered by skipLibCheck) under a Workers-typed, strict tsc configuration.
Changes:
- Narrow the
response.json()error body inwordpress-plugin.tsfromunknownbefore reading.message(fixes TS18046 in strict consumer builds). - Add
scripts/typecheck-public-source.mjs+ a committed baseline to snapshot/guard shipped-source diagnostics per(file, TS code). - Add a
fixtures/public-types/consumer fixture and wire the harness into CI.
Reviewed changes
Copilot reviewed 8 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/typecheck-public-source.mjs | New harness that enumerates source-exported subpaths, runs strict tsc, filters boundaries, and compares diagnostic counts to a baseline. |
| scripts/typecheck-public-source.baseline.json | Baseline snapshot of existing (file, errorCode) diagnostic groups to prevent regressions. |
| packages/core/src/import/sources/wordpress-plugin.ts | Fix: narrow unknown JSON error body before accessing .message. |
| fixtures/public-types/package.json | New strict-consumer fixture package with Workers types + TypeScript. |
| fixtures/public-types/tsconfig.json | Strict tsc config used by the harness to emulate consumer typechecking. |
| fixtures/public-types/env.d.ts | References emdash/locals to mirror real consumer globals. |
| fixtures/public-types/shims.d.ts | Minimal type stubs needed for the hermetic fixture (currently astro:assets). |
| fixtures/public-types/.gitignore | Ignores generated entrypoint file used by the harness. |
| .github/workflows/ci.yml | Adds the public-source typecheck harness to the CI typecheck job. |
| pnpm-lock.yaml | Adds the new fixture workspace importer dependencies to the lockfile. |
| .changeset/wordpress-plugin-error-narrowing.md | Changeset documenting the consumer-facing typecheck fix. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "compilerOptions": { | ||
| "types": ["@cloudflare/workers-types"], | ||
| "noUncheckedSideEffectImports": true, | ||
| "noEmit": true |
| ); | ||
| } | ||
|
|
||
| const parsed = parseDiagnostics(output); | ||
| if (rawErrorCount > 0 && parsed.length === 0) { | ||
| fail( | ||
| `tsc reported ${rawErrorCount} error line(s) but the parser matched none -- ` + | ||
| `diagnostic format drifted; the guard would silently pass. Fix DIAGNOSTIC_LINE.`, | ||
| ); | ||
| } | ||
|
|
|
Superseded by #1076, which resolves #1053 as one coherent change: the |
What does this PR do?
Closes #1053.
Fixes the one real type error #1053 reported, and adds a regression guard so the whole class can't ship again.
The reporter's two errors, re-triaged:
byline.ts:204(TS2345 kyselyTransaction→Kysely) — a TypeScript 5.x variance behaviour. It does not reproduce on TypeScript 6 and is already resolved by the TS6 upgrade in chore: upgrade to TypeScript 6 + pin tsgo beta + fix dual-load config #1074 (merged). No code change needed.wordpress-plugin.ts(TS18046'error' is of type 'unknown') — real. The analyze-endpoint error body fromresponse.json()isunknownunder@cloudflare/workers-typesand was read without narrowing. This file ships as raw source via theemdash/routes/*export, so it fails strict consumer typechecks. Fixed with assertion-free narrowing (clean under both the consumer's Workers-typed config and emdash's ownastro/clienttypecheck; noas, no lint warning, runtime unchanged).The reporter's premise was right, their repro was wrong. Bare
import "emdash"resolves to compileddist/*.d.mtsandskipLibCheckcovers it — verified clean. The errors only surface through the source-exported subpaths (emdash/routes/*,emdash/ui,emdash/api/*,emdash/auth/providers/*), which ship raw.tsthatskipLibCheckcannot skip. Our ownpnpm typecheckmisses this: it runstsgoagainst our lenient tsconfig (excludessrc/astro/**, no Workers types). A strict consumer on realtscdeployed to Workers sees a different program.Regression guard (
scripts/typecheck-public-source.mjs+fixtures/public-types/): reconstructs the consumer view — realtsc,@cloudflare/workers-types,emdash/locals— over every.ts/.tsxsource-exported subpath, and compares per-(file, errorCode)diagnostic counts to a committed baseline (same idea as the perf query-count snapshot). Wired into the CI typecheck job..astro/virtual:emdash/*(allowlisted) module-resolution surface is the documented boundary — a hermetic type-only harness can't resolve it; real sites do, viaastro check(covered by the demo/template typecheck jobs).node_modules/diagnostics are dropped (third-party, unstable pnpm-store paths).tscoutcome fail loudly (unexpected exit code, unparseable error lines / format drift, exit-0-with-errors, path-rooting drift) — the guard can't silently pass.wordpress-plugin.tsTS18046 never returns, independent of the baseline file. TDD-verified: reverting the fix makes the harness FAIL naming exactly that error; restored → green.ui.ts/astro-portabletext, dual-packageKyselyrealm,Locals.tokenScopes, import payload shapes). Tracked separately and burned down incrementally; the harness fails on any growth or new shipped-source error, shrinking as debt is fixed.Built on #1074 (TS6). Adversarially reviewed twice (the narrowing fix and the harness); review found four false-pass/flaky vectors in the harness, all fixed before this PR (exit/parse sanity gates, count-based baseline, node_modules exclusion, tightened virtual allowlist).
Type of change
Checklist
pnpm typecheckpassespnpm lintpasses (PR adds 0 diagnostics; repo baseline of 38 unchanged)pnpm testpasses (or targeted tests for my change) — the harness itself is the regression test (TDD red/green proven via the Type errors in emdash 0.12.0 under strict TypeScript #1053 sentinel); the one-line narrowing has no behavioural change to unit-testpnpm formathas been runemdashpatch for the wordpress-plugin narrowing fixAI-generated code disclosure