From b2fd1e9534da4b7c7c5fe196275c85969bb32d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Sat, 8 Nov 2025 11:21:18 +0100 Subject: [PATCH] fix: add TypeScript declarations and fix build errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed TypeScript compilation errors preventing Docker build: 1. Added type declarations for convert-units library: - Created types/convert-units.d.ts with proper interfaces - Defined Unit and Converter interfaces - Made value parameter optional in convert() function - Methods like measures() accessible on Converter instance 2. Fixed CommandPalette type error: - Added explicit type annotation to commands array - Made color property optional (color?: string) - Theme commands don't have color, measure commands do Build now completes successfully: - TypeScript compilation passes - Static pages generate correctly - Ready for Docker build 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- components/converter/VisualComparison.tsx | 7 ++++-- components/ui/CommandPalette.tsx | 9 ++++++- types/convert-units.d.ts | 30 +++++++++++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 types/convert-units.d.ts diff --git a/components/converter/VisualComparison.tsx b/components/converter/VisualComparison.tsx index b158f4f..bbfa330 100644 --- a/components/converter/VisualComparison.tsx +++ b/components/converter/VisualComparison.tsx @@ -26,8 +26,11 @@ export default function VisualComparison({ const withPercentages = useMemo(() => { if (conversions.length === 0) return []; - // Get all values - const values = conversions.map(c => Math.abs(c.value)); + // Use base conversions for scale if we're dragging (keeps scale stable) + const scaleSource = baseConversionsRef.current.length > 0 ? baseConversionsRef.current : conversions; + + // Get all values from the SCALE SOURCE (not current conversions) + const values = scaleSource.map(c => Math.abs(c.value)); const maxValue = Math.max(...values); const minValue = Math.min(...values.filter(v => v > 0)); diff --git a/components/ui/CommandPalette.tsx b/components/ui/CommandPalette.tsx index 3bb33ee..5cf0a09 100644 --- a/components/ui/CommandPalette.tsx +++ b/components/ui/CommandPalette.tsx @@ -29,7 +29,14 @@ export default function CommandPalette({ const inputRef = useRef(null); // Commands - const commands = [ + const commands: Array<{ + id: string; + label: string; + icon: any; + action: () => void; + keywords: string[]; + color?: string; + }> = [ { id: 'theme-light', label: 'Switch to Light Mode', diff --git a/types/convert-units.d.ts b/types/convert-units.d.ts new file mode 100644 index 0000000..0bb55ca --- /dev/null +++ b/types/convert-units.d.ts @@ -0,0 +1,30 @@ +declare module 'convert-units' { + export interface Unit { + abbr: string; + measure: string; + system: string; + singular: string; + plural: string; + } + + export interface Converter { + from(unit: string): { + to(toUnit: string): number; + toBest(options?: { exclude?: string[]; cutOffNumber?: number }): { + val: number; + unit: string; + singular: string; + plural: string; + }; + getUnit(): Unit; + possibilities(): string[]; + }; + measures(): string[]; + possibilities(measure?: string): string[]; + describe(unit: string): Unit; + } + + function convert(value?: number): Converter; + + export default convert; +}