Skip to content

Commit cb2a832

Browse files
Update type definitions for improved type safety in HomeClient, HeroScene, and TerminalCanvas components
1 parent c139634 commit cb2a832

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/components/HomeClient.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function useMediaQuery(query: string) {
3535
return matches;
3636
}
3737

38-
function useScrollProgress(ref: RefObject<HTMLElement>) {
38+
function useScrollProgress(ref: RefObject<HTMLElement | null>) {
3939
const [progress, setProgress] = useState(0);
4040

4141
useEffect(() => {
@@ -266,7 +266,7 @@ function ProjectCard({
266266
project: {
267267
title: string;
268268
year: string;
269-
tags: string[];
269+
tags: readonly string[];
270270
summary: string;
271271
detailsMd?: string;
272272
links: {

src/components/hero/HeroScene.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ function ComputerModel({
116116
screenMeshRef.current = screenMesh;
117117
}
118118

119+
const screenMeshName: string | null =
120+
(screenMesh as Mesh | null)?.name ?? null;
121+
119122
if (!screenMesh) {
120123
const bounds = new Box3().setFromObject(scene);
121124
const size = bounds.getSize(new Vector3());
@@ -127,12 +130,12 @@ function ComputerModel({
127130
plane.name = "FallbackScreen";
128131
scene.add(plane);
129132
fallbackPlaneRef.current = plane;
130-
onDebug({ meshNames, screenMeshName: null, fallbackPlane: true });
133+
onDebug({ meshNames, screenMeshName, fallbackPlane: true });
131134
if (process.env.NEXT_PUBLIC_DEVTOOLS === "1") {
132135
console.info("screen mesh not found, using fallback plane");
133136
}
134137
} else {
135-
onDebug({ meshNames, screenMeshName: screenMesh.name, fallbackPlane: false });
138+
onDebug({ meshNames, screenMeshName, fallbackPlane: false });
136139
}
137140
}, [onDebug, scene]);
138141

@@ -278,8 +281,10 @@ function SceneContent({
278281
const eased = scrollProgress * scrollProgress;
279282
camera.position.set(base.x, base.y - eased * 0.2, base.z + eased * 2.8);
280283
camera.lookAt(0, 0.2, 0);
281-
camera.fov = base.fov;
282-
camera.updateProjectionMatrix();
284+
if ("fov" in camera) {
285+
camera.fov = base.fov;
286+
camera.updateProjectionMatrix();
287+
}
283288

284289
if (groupRef.current) {
285290
const tiltX = parallax.current.y * 0.04;

src/components/terminal/TerminalCanvas.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type Theme = {
3232

3333
type TerminalCanvasProps = {
3434
files: TerminalFile[];
35-
introLines: string[];
35+
introLines: readonly string[];
3636
prompt: string;
3737
helpText: string;
3838
theme: Theme;

0 commit comments

Comments
 (0)