Skip to content

Commit 8ab029e

Browse files
fix: declare custom <piece> JSX element for Chessground compatibility
Add module augmentation for the <piece> intrinsic element used by Chessground's CSS sprite system, fixing TS2339 build error. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9bcb458 commit 8ab029e

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

src/components/Board/GameClock.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ export const GameClock: React.FC<Props> = (
5959
const showTenths = minutes < 1 && seconds <= 20
6060

6161
return (
62-
<div
63-
className="flex flex-row items-center justify-between bg-glass-strong md:flex-col md:items-start md:justify-start"
64-
>
62+
<div className="flex flex-row items-center justify-between bg-glass-strong md:flex-col md:items-start md:justify-start">
6563
<div className="flex w-full items-center justify-between gap-3 px-4 py-2">
6664
<span
6765
className={`flex items-center gap-2 transition-colors ${
@@ -96,9 +94,7 @@ export const GameClock: React.FC<Props> = (
9694
</div>
9795
<div
9896
className={`inline-flex self-start px-4 py-2 transition-all duration-200 md:text-3xl ${
99-
active
100-
? 'font-semibold text-primary'
101-
: 'text-white/55'
97+
active ? 'font-semibold text-primary' : 'text-white/55'
10298
}`}
10399
>
104100
{minutes}:{('00' + seconds).slice(-2)}

src/components/Common/MaterialBalance.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ import { useMemo } from 'react'
22
import type { Color } from 'src/types'
33
import { Chess } from 'chess.ts'
44

5+
declare module 'react' {
6+
// eslint-disable-next-line @typescript-eslint/no-namespace
7+
namespace JSX {
8+
interface IntrinsicElements {
9+
piece: React.DetailedHTMLProps<
10+
React.HTMLAttributes<HTMLElement>,
11+
HTMLElement
12+
>
13+
}
14+
}
15+
}
16+
517
type PieceType = 'p' | 'n' | 'b' | 'r' | 'q' | 'k'
618
type MaterialCount = Record<PieceType, number>
719

@@ -170,8 +182,7 @@ export const MaterialBalance = ({
170182

171183
const capturedPieceColor = color === 'white' ? 'black' : 'white'
172184
const capturedPieceFilter =
173-
pieceFilter ??
174-
capturedPieceColor === 'black'
185+
(pieceFilter ?? capturedPieceColor === 'black')
175186
? 'drop-shadow(0 0 0.8px rgba(255,255,255,0.82)) drop-shadow(0 0 1.5px rgba(255,255,255,0.28))'
176187
: 'drop-shadow(0 0 0.8px rgba(0,0,0,0.82)) drop-shadow(0 0 1.5px rgba(0,0,0,0.22))'
177188

0 commit comments

Comments
 (0)