Replace all socket/game string literals with enums; fix broken socket.ts; remove type/null assertions#22
Replace all socket/game string literals with enums; fix broken socket.ts; remove type/null assertions#22Copilot wants to merge 30 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: LachlanBWWright <79518204+LachlanBWWright@users.noreply.github.com>
…s, update clients Co-authored-by: LachlanBWWright <79518204+LachlanBWWright@users.noreply.github.com>
Co-authored-by: LachlanBWWright <79518204+LachlanBWWright@users.noreply.github.com>
…, add ID note Co-authored-by: LachlanBWWright <79518204+LachlanBWWright@users.noreply.github.com>
Co-authored-by: LachlanBWWright <79518204+LachlanBWWright@users.noreply.github.com>
|
The code is not of an adequate quality. I do not want re-exports and any 'backward compatibility' solutions, I want a clean solution. You need to find and remove ALL type assertions from the project, all uses of 'any' and all lines of code that disable linters and typescript checks - they are not acceptable. I do not want useMemo and useCallback to be used in any capacity throughout the project, and I want the general approach to environment variables to be cleaned up (i.e. a single backend url, not separate ones for if partykit/sockedio is used). The lobby/page.tsx file is particularly egregious, you need to get logic out of React components, and if need be, move them to hook functions. Make sure .env.example files describe the ALL environment variables used. The before-commit-verify.sh script should pass without issues. Take a timestamp at the start of your session. You must work for at least 50 minutes. |
…-disable; unify env vars; extract lobby hook Co-authored-by: LachlanBWWright <79518204+LachlanBWWright@users.noreply.github.com>
Co-authored-by: LachlanBWWright <79518204+LachlanBWWright@users.noreply.github.com>
Done in commits Type safety / assertions removed:
No
Logic out of React components:
Environment variables:
Script compliance:
|
… User-Player-Role refactor; replace raw SQL with Drizzle; prune unused server deps; clean tsconfigs; add CI workflow Co-authored-by: LachlanBWWright <79518204+LachlanBWWright@users.noreply.github.com>
… Home and HowToPlay screens
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
- Create shared/trpc/validators.ts with MatchHistoryEventSchema using discriminated unions - Add deserializeEventHistory() and deserializeStringArray() for type-safe deserialization - Replace generic parseArray/parseCount with validated deserializers in services.ts - Update appRouter.ts to use MatchHistoryEventSchema in tRPC input validation - Remove unnecessary type assertion in persistMatch mutation - All JSON parsing now validated at compile-time with Zod, no more stringly-typed unvalidated data - All tests passing (41 tests in server suite) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Widespread stringly-typed socket events,
"Day" | "Night"string unions,as Ttype casts, and!null assertions throughout the codebase.shared/logic/socket.tswas a bareuseEffectfragment with no imports, exports, or types — effectively broken.Enums
DayTime(shared/game/playerActionRules.ts):type DayTime = "Day" | "Night"→export enum DayTime { Day = "Day", Night = "Night" }. RemovednormalizeTime()helper; all comparisons use the enum directly.GamePhase(server/model/rooms/gamePhase.ts, new):Idle | Day | Night | Processing— replaces the"day" | "night" | "" | "undefined"string union onRoom.time.ServerEvent/ClientEvent: allsocket.on("receiveMessage", ...)/socket.emit("playerJoinRoom", ...)style calls replaced acrossnextjs,mobile,server/servers, and tests.shared/logic/socket.ts— complete rewriteExports
registerGameSocketEvents(socket, callbacks): () => voidand a typedGameEventCallbacksinterface. Zero raw strings; returns a cleanup function. SRP/OCP/DIP compliant.Type safety
partykitServer.ts:as [string, boolean]tuple assertions replaced with explicittypeofruntime guards before use.abstractRole.ts:nightTapped as Role→nightTapped instanceof Role;faction!.handleNightMessagenon-null assertion → local narrowed const.partykitClientAdapter.ts:listeners.get(event)!→ explicit null-check.room.ts:typeof senderTap === "object"→senderTap instanceof Role.Protocol
update-day-timepayloadtimefield typed asDayTime(was"Day" | "Night"string literal).shared/communication/index.tsnow exportsServerEvent,ClientEvent, andDayTimefor single-import convenience.Tests
All four test files (
communication.test.ts,serverAdapter.test.ts,playerActionRules.test.ts,appRouter.test.ts) updated to use enum values instead of raw strings.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.