Skip to content

Commit 855cc74

Browse files
adewaleclaude
andcommitted
fix: Resolve TypeScript type narrowing errors in drag-to-paint tests
TypeScript was narrowing the `paintMode` variable type from `'on' | 'off' | null` to just `'off'`, causing TS2367 errors when comparing to 'on'. Fixed by casting the value to the full union type. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 860c88a commit 855cc74

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

app/src/components/drag-to-paint.test.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ describe('Paint Mode State Management', () => {
8585

8686
it('should toggle step to inactive when paintMode is "off" and step is active', () => {
8787
const steps = [true, true, true, true];
88-
const paintMode: 'on' | 'off' | null = 'off';
88+
// Cast to union type to prevent TypeScript from narrowing to literal
89+
const paintMode = 'off' as 'on' | 'off' | null;
8990
const toggledSteps: number[] = [];
9091

9192
const handlePaintEnter = (stepIndex: number) => {
@@ -125,7 +126,8 @@ describe('Paint Mode State Management', () => {
125126

126127
it('should NOT toggle step when paintMode is "off" and step is already inactive', () => {
127128
const steps = [false, false, false, false];
128-
const paintMode: 'on' | 'off' | null = 'off';
129+
// Cast to union type to prevent TypeScript from narrowing to literal
130+
const paintMode = 'off' as 'on' | 'off' | null;
129131
const toggledSteps: number[] = [];
130132

131133
const handlePaintEnter = (stepIndex: number) => {

0 commit comments

Comments
 (0)