From 365b2c4d13fa50e6f12487ce332c90d55db37370 Mon Sep 17 00:00:00 2001 From: hypercross Date: Tue, 2 Jun 2026 18:05:47 +0800 Subject: [PATCH] fix: handle edge object in serialization tests Add `typecheck` script to package.json, expand tsconfig include paths to cover tests and examples, and update serialization tests to correctly resolve player IDs from relationship edges. --- package.json | 1 + test/serialization.test.ts | 4 +++- tsconfig.json | 5 ++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index e9e9812..1f11af8 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "scripts": { "build": "tsup", "dev": "tsup --watch", + "typecheck": "tsc --noEmit", "test": "vitest run", "prepublishOnly": "npm run build" }, diff --git a/test/serialization.test.ts b/test/serialization.test.ts index 81c9d16..3cd8809 100644 --- a/test/serialization.test.ts +++ b/test/serialization.test.ts @@ -277,7 +277,9 @@ describe("Serialization — complex state", () => { const comps = snap.entities[id]; return comps.position && comps.velocity && !comps.health; })!; - const playerId = snap.relationships.ownedBy[bulletId]; + const playerEdge = snap.relationships.ownedBy[bulletId]; + const playerId = + typeof playerEdge === "string" ? playerEdge : playerEdge.target; // Player should have a name const playerComps = snap.entities[playerId]; diff --git a/tsconfig.json b/tsconfig.json index 79c151c..70ba655 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,8 +11,7 @@ "declarationMap": true, "sourceMap": true, "outDir": "./dist", - "rootDir": "./src" }, - "include": ["src"], - "exclude": ["node_modules", "dist"] + "include": ["src", "test", "examples"], + "exclude": ["node_modules", "dist"], }