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' } from './errors'
import { authStore } from '$lib/stores/auth.store' import { authStore } from '$lib/stores/auth.store'
import { browser } from '$app/environment' import { browser } from '$app/environment'
import { optionalProps } from '$lib/utils/typeShims'
/** /**
* Base adapter class that all resource-specific adapters extend from. * 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 = { const fetchOptions: RequestInit = {
...optionalProps(options), // Allow overriding defaults, filter undefined ...options, // Allow overriding defaults
credentials: 'include', // Still include cookies for CORS and refresh token credentials: 'include', // Still include cookies for CORS and refresh token
signal: controller.signal, signal: controller.signal,
headers: { headers: {

View file

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

View file

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

View file

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

View file

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