From 4a9ea3604c1717a5acc126b2514489c7a89e3cf6 Mon Sep 17 00:00:00 2001 From: Reimar Date: Thu, 16 Oct 2025 11:07:52 +0200 Subject: [PATCH] write correct type name in error --- src/gamelib_adapter.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gamelib_adapter.js b/src/gamelib_adapter.js index 45fd4f6..de1be33 100644 --- a/src/gamelib_adapter.js +++ b/src/gamelib_adapter.js @@ -88,18 +88,21 @@ export class GamelibAdapter { for (let i = 0; i < args.length; i++) { const expectedType = typeAliases[expectedTypes[i]] ?? expectedTypes[i]; + let expectedTypeName = typeAliases[expectedTypes[i]] ? expectedTypes[i] : null; if (typeof expectedType === "string" && typeof args[i] !== expectedType) { + expectedTypeName ??= expectedType; + this.#error( `Expected parameter #${ i + 1 - } to be of type ${expectedType}, got ${typeof args[i]}`, + } to be of type ${expectedTypeName}, got ${typeof args[i]}`, func, ); } if (expectedType instanceof Object && !(args[i] instanceof expectedType)) { - const expectedTypeName = expectedType.prototype.constructor.name; + expectedTypeName ??= expectedType.prototype.constructor.name; this.#error( `Expected parameter #${