Skip to content

fix: make CWD API typecheck clean and enforce CI - #26

Open
stevenjoezhang wants to merge 1 commit into
anghunk:mainfrom
stevenjoezhang:agent/fix-typescript-checks
Open

fix: make CWD API typecheck clean and enforce CI#26
stevenjoezhang wants to merge 1 commit into
anghunk:mainfrom
stevenjoezhang:agent/fix-typescript-checks

Conversation

@stevenjoezhang

Copy link
Copy Markdown

Summary

  • type Telegram Bot API response envelopes instead of reading properties from unknown
  • use the typed xss whiteList named export in both comment handlers
  • add Telegram success and error response tests
  • add a reusable pnpm typecheck command
  • add CWD API CI for frozen dependency installation, typechecking, tests, and manual runs
  • synchronize the existing lockfile with package.json so frozen installs work

Root cause

Cloudflare's Response.json() correctly defaults to unknown, but the Telegram handlers consumed its result without a response type. The xss package exposes whiteList as a named export in its declarations, while the handlers accessed it as a property of the default callable export.

The repository had no typecheck script or CI job, so these errors did not block deployment. The checked-in lockfile had also drifted from cwd-api/package.json (aws4fetch was missing and the Wrangler range was stale), which prevented a frozen CI install.

Impact

cwd-api now passes strict TypeScript checking. Runtime Telegram and XSS behavior is unchanged. Pull requests that touch the API will install from the frozen lockfile and run both typechecking and tests.

Validation

  • pnpm install --frozen-lockfile --ignore-scripts
  • pnpm typecheck
  • pnpm test --run (4 files, 12 tests passed)
  • wrangler deploy --dry-run --config wrangler.jsonc
  • workflow YAML parse and git diff --check

@stevenjoezhang
stevenjoezhang marked this pull request as ready for review July 29, 2026 17:45
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.

1 participant