write correct type name in error

This commit is contained in:
Reimar 2025-10-16 11:07:52 +02:00
parent 2715ca401b
commit 4a9ea3604c

View File

@ -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 #${