fix(arcade): resolve TypeScript errors in game config helpers
Fixed three TypeScript compilation errors: 1. game-config-helpers.ts:82 - Cast existing.config to object for spread 2. game-config-helpers.ts:116 - Fixed dynamic field assignment in updateGameConfigField 3. MatchingGameValidator.ts:540 - Use proper Difficulty type in MatchingGameConfig Changes: - Import Difficulty and GameType from matching types - Update MatchingGameConfig to use proper union types - Cast existing.config as object before spreading - Rewrite updateGameConfigField to avoid type assertion issue All TypeScript errors resolved. Compilation passes cleanly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -79,7 +79,7 @@ export async function setGameConfig<T extends GameName>(
|
||||
|
||||
if (existing) {
|
||||
// Update existing config (merge with existing values)
|
||||
const mergedConfig = { ...existing.config, ...config }
|
||||
const mergedConfig = { ...(existing.config as object), ...config }
|
||||
await db
|
||||
.update(schema.roomGameConfigs)
|
||||
.set({
|
||||
@@ -113,7 +113,10 @@ export async function updateGameConfigField<
|
||||
T extends GameName,
|
||||
K extends keyof GameConfigByName[T],
|
||||
>(roomId: string, gameName: T, field: K, value: GameConfigByName[T][K]): Promise<void> {
|
||||
await setGameConfig(roomId, gameName, { [field]: value } as Partial<GameConfigByName[T]>)
|
||||
// Create a partial config with just the field being updated
|
||||
const partialConfig: Partial<GameConfigByName[T]> = {} as any
|
||||
;(partialConfig as any)[field] = value
|
||||
await setGameConfig(roomId, gameName, partialConfig)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,13 +10,14 @@
|
||||
*/
|
||||
|
||||
import type { DifficultyLevel } from '@/app/arcade/memory-quiz/types'
|
||||
import type { Difficulty, GameType } from '@/app/games/matching/context/types'
|
||||
|
||||
/**
|
||||
* Configuration for matching (memory pairs) game
|
||||
*/
|
||||
export interface MatchingGameConfig {
|
||||
gameType: 'abacus-numeral' | 'complement-pairs'
|
||||
difficulty: number
|
||||
gameType: GameType
|
||||
difficulty: Difficulty
|
||||
turnTimer: number
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user