[DevEx]: Close the last 5 backend environment type gaps

Open
#1,402 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
62/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, nodejs
Domain
devtools, testing

Research direction

Read the five listed TypeScript errors in api/helpers/game-states/validate-all-cards.js, utils/config-utils.js, utils/dev-ports.js, and api/responses/forbidden.js, along with the relevant type-check configuration. First land or account for #1397 and #1411, then run npm run typecheck:backend with checkJs: true. Done means the backend reports zero errors without behavior changes.

Written by the indexing model from the issue text.

Description

backend dev experience

Part of #1399. Depends on #1401. Overlaps #1397.

Summary

Clear the last backend type errors so the gate in #1404 can be strict from day one. After #1401 there are 27; 14 of them are fixed by #1397 alone and 8 more are split out into #1411, leaving 5 environment gaps here.

What's left after #1401

14 × TS2307 — already fixed by #1397. Every one is an extensionless require of a JSON enum:

api/controllers/game/{move,ready}.js, .../ai/{ai-move,create-vs-ai}.js,
.../spectate/join.js, api/controllers/StatsController.js,
api/helpers/{find-open-games,find-spectatable-games,is-game-full}.js,
api/hooks/customGameHook/index.js            -> utils/GameStatus
api/helpers/game-states/ai/{get-legal-moves,get-move-bodies-for-move-type}.js,
.../ai/minimax/get-minimax-score.js           -> utils/MoveType, utils/TargetType

Nothing to do here beyond landing #1397 first.

8 × malformed JSDoc (TS1005 + TS8024) in StatsController.js and convert-card-to-str.js — split out into #1411 as a comment-only change. Land that first or alongside this.

5 × environment gaps (TS2339), each needing a small declaration or config tweak rather than a code change:

Site Error Likely fix
api/helpers/game-states/validate-all-cards.js:59 Property 'difference' does not exist on type 'Set<string>' Set.prototype.difference is ES2025; raise lib or use a helper
utils/config-utils.js:7 Property 'Cypress' does not exist on Window declare it (shared with #1403)
utils/config-utils.js:14 Property 'cuttle' does not exist on Window same
utils/dev-ports.js:30 Property 'loadEnvFile' does not exist on type 'Process' Node 22 API; needs current @types/node
api/responses/forbidden.js:3 Property 'res' does not exist on type '{ exports: ... }' sails binds this to the request context; see note below

On forbidden.js: sails invokes custom responses with this bound to a req/res context, which TypeScript cannot infer — it sees this as the module object. Since the project does not use JSDoc for type declarations (#1399), prefer declaring the sails response context in a .d.ts alongside the globals from #1401. If that proves awkward for a 3-line file, a single @this annotation is an acceptable documented exception — say so in the PR rather than quietly setting the precedent.

Note utils/config-utils.js is consumed by both the client and the server, so its two window errors appear in the frontend run too — fixing them here clears them from both.

Not in this issue

The two MoveType enum errors that checkJs originally surfaced here (get-log.js referencing SEVEN_UNTARGETED_ONE_OFF / SEVEN_TARGETED_ONE_OFF) are already fixed in #1398, which is why the count is 13 and not 15. They are the proof this whole exercise is worth doing: three shipped bugs, none caught by lint, unit tests, or e2e.

Acceptance
  • With #1397 and #1411 landed, npm run typecheck:backend under checkJs: true reports 0 errors
  • No behavior change — every item here is a declaration or a config value
Dominant language
JavaScript
Stars
195
Forks
145
Avg merge
1d 7h
Merged PRs (30d)
32

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cuttle-cards/cuttle

All issues in cuttle-cards/cuttle

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.