fix(types): update types in LuaScriptDetails and PackageFilters components for better type safety

This commit is contained in:
2025-12-30 00:40:26 +00:00
parent 021762bd50
commit f93945ad79
3 changed files with 22 additions and 5 deletions

View File

@@ -2,15 +2,16 @@ import { Plus, Trash } from '@phosphor-icons/react'
import { Badge, Button, CardContent, Input, Label } from '@/components/ui'
import type { LuaScript } from '@/lib/level-types'
import type { JsonValue } from '@/types/utility-types'
interface LuaScriptDetailsProps {
script: LuaScript
testInputs: Record<string, any>
testInputs: Record<string, JsonValue>
onUpdateScript: (updates: Partial<LuaScript>) => void
onAddParameter: () => void
onDeleteParameter: (index: number) => void
onUpdateParameter: (index: number, updates: { name?: string; type?: string }) => void
onTestInputChange: (paramName: string, value: any) => void
onTestInputChange: (paramName: string, value: JsonValue) => void
}
export const LuaScriptDetails = ({

View File

@@ -13,6 +13,12 @@ interface PackageFiltersProps {
onSortChange: (value: 'name' | 'downloads' | 'rating') => void
}
type SortBy = PackageFiltersProps['sortBy']
function isSortBy(value: string): value is SortBy {
return value === 'name' || value === 'downloads' || value === 'rating'
}
export function PackageFilters({
searchQuery,
categoryFilter,
@@ -52,7 +58,12 @@ export function PackageFilters({
</SelectContent>
</Select>
<Select value={sortBy} onValueChange={value => onSortChange(value as any)}>
<Select
value={sortBy}
onValueChange={value => {
if (isSortBy(value)) onSortChange(value)
}}
>
<SelectTrigger className="w-[180px]">
<TrendUp size={16} className="mr-2" />
<SelectValue placeholder="Sort by" />

View File

@@ -4,7 +4,12 @@ import { useState } from 'react'
import { toast } from 'sonner'
import { Button } from '@/components/ui'
import type { BuilderState, ComponentDefinition, ComponentInstance } from '@/lib/builder-types'
import type {
BuilderState,
ComponentDefinition,
ComponentInstance,
ComponentProps,
} from '@/lib/builder-types'
import { Canvas } from './Canvas'
import { CodeEditor } from './CodeEditor'
@@ -63,7 +68,7 @@ export function Builder({ onLogout }: BuilderProps) {
})
}
const handleUpdateProps = (id: string, props: any) => {
const handleUpdateProps = (id: string, props: ComponentProps) => {
setBuilderState(current => {
if (!current) return { components: [], selectedId: null }
return {