fix: Phase 2 - remove optionalProps() shim misuse (45 -> 43 errors)

Removed inappropriate use of optionalProps() type shim from our own
codebase where we control the types. Type shims should only be used
for third-party library incompatibilities.

Files modified:
- base.adapter.ts: Removed shim from RequestOptions spreading
- grid.service.ts: Removed 3 usages from update methods
- party.service.ts: Removed import
- users.ts: Removed import and usage
- UserSettingsModal.svelte: Direct object construction
- drag-drop.svelte.ts: Direct object for DragOperation.target

Result: 45 → 43 errors (-2)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Justin Edmund 2025-11-28 19:23:14 -08:00
parent 8fd7a6fb11
commit 5d98bba30c
6 changed files with 13 additions and 19 deletions

View file

@ -19,7 +19,6 @@ import {
} from './errors'
import { authStore } from '$lib/stores/auth.store'
import { browser } from '$app/environment'
import { optionalProps } from '$lib/utils/typeShims'
/**
* Base adapter class that all resource-specific adapters extend from.
@ -125,9 +124,9 @@ export abstract class BaseAdapter {
}
}
// Prepare request options (filter out undefined to satisfy exactOptionalPropertyTypes)
// Prepare request options
const fetchOptions: RequestInit = {
...optionalProps(options), // Allow overriding defaults, filter undefined
...options, // Allow overriding defaults
credentials: 'include', // Still include cookies for CORS and refresh token
signal: controller.signal,
headers: {

View file

@ -1,5 +1,4 @@
import { userAdapter } from '../adapters/user.adapter'
import { optionalProps } from '$lib/utils/typeShims'
export interface UserUpdateParams {
picture?: string | undefined

View file

@ -10,7 +10,6 @@
import type { UserCookie } from '$lib/types/UserCookie'
import { setUserCookie } from '$lib/auth/cookies'
import { invalidateAll } from '$app/navigation'
import { optionalProps } from '$lib/utils/typeShims'
interface Props {
open: boolean
@ -73,14 +72,14 @@
saving = true
try {
// Prepare the update data (filter undefined to satisfy exactOptionalPropertyTypes)
const updateData = optionalProps({
// Prepare the update data
const updateData = {
picture,
element: currentPicture?.element,
gender,
language,
theme
})
}
// Call API to update user settings
const response = await users.update(userId, updateData)

View file

@ -1,5 +1,4 @@
import type { GridCharacter, GridWeapon, GridSummon } from '$lib/types/api/party'
import { optionalProps } from '$lib/utils/typeShims'
export type GridItemType = 'character' | 'weapon' | 'summon'
export type GridItem = GridCharacter | GridWeapon | GridSummon
@ -225,12 +224,12 @@ export function createDragDropContext(handlers: DragDropHandlers = {}) {
itemId: state.draggedItem.data.id,
type: state.draggedItem.source.type
},
target: optionalProps({
target: {
container: state.hoveredOver.container,
position: state.hoveredOver.position,
itemId: targetItem?.id,
type: state.hoveredOver.type
}),
},
status: 'pending',
retryCount: 0
}

View file

@ -1,7 +1,6 @@
import type { Party, GridWeapon, GridSummon, GridCharacter } from '$lib/types/api/party'
import { gridAdapter } from '$lib/api/adapters/grid.adapter'
import { partyAdapter } from '$lib/api/adapters/party.adapter'
import { optionalProps } from '$lib/utils/typeShims'
export interface GridOperation {
type: 'add' | 'replace' | 'remove' | 'move' | 'swap'
@ -123,12 +122,12 @@ export class GridService {
editKey?: string,
options?: { shortcode?: string }
): Promise<Party | null> {
await gridAdapter.updateWeapon(gridWeaponId, optionalProps({
await gridAdapter.updateWeapon(gridWeaponId, {
position: updates.position,
uncapLevel: updates.uncapLevel,
transcendenceStep: updates.transcendenceStep,
element: updates.element
}), this.buildHeaders(editKey))
}, this.buildHeaders(editKey))
// Clear party cache if shortcode provided
if (options?.shortcode) {
@ -271,12 +270,12 @@ export class GridService {
editKey?: string,
options?: { shortcode?: string }
): Promise<Party | null> {
await gridAdapter.updateSummon(gridSummonId, optionalProps({
await gridAdapter.updateSummon(gridSummonId, {
position: updates.position,
quickSummon: updates.quickSummon,
uncapLevel: updates.uncapLevel,
transcendenceStep: updates.transcendenceStep
}), this.buildHeaders(editKey))
}, this.buildHeaders(editKey))
// Clear party cache if shortcode provided
if (options?.shortcode) {
@ -437,12 +436,12 @@ export class GridService {
editKey?: string,
options?: { shortcode?: string }
): Promise<GridCharacter | null> {
const updated = await gridAdapter.updateCharacter(gridCharacterId, optionalProps({
const updated = await gridAdapter.updateCharacter(gridCharacterId, {
position: updates.position,
uncapLevel: updates.uncapLevel,
transcendenceStep: updates.transcendenceStep,
perpetuity: updates.perpetuity
}), this.buildHeaders(editKey))
}, this.buildHeaders(editKey))
// Clear party cache if shortcode provided
if (options?.shortcode) {

View file

@ -2,7 +2,6 @@ import type { Party } from '$lib/types/api/party'
import { partyAdapter } from '$lib/api/adapters/party.adapter'
import { authStore } from '$lib/stores/auth.store'
import { browser } from '$app/environment'
import { optionalProps } from '$lib/utils/typeShims'
/**
* Context type for party-related operations in components