write correct type name in error
This commit is contained in:
parent
2715ca401b
commit
4a9ea3604c
@ -88,18 +88,21 @@ export class GamelibAdapter {
|
|||||||
|
|
||||||
for (let i = 0; i < args.length; i++) {
|
for (let i = 0; i < args.length; i++) {
|
||||||
const expectedType = typeAliases[expectedTypes[i]] ?? expectedTypes[i];
|
const expectedType = typeAliases[expectedTypes[i]] ?? expectedTypes[i];
|
||||||
|
let expectedTypeName = typeAliases[expectedTypes[i]] ? expectedTypes[i] : null;
|
||||||
|
|
||||||
if (typeof expectedType === "string" && typeof args[i] !== expectedType) {
|
if (typeof expectedType === "string" && typeof args[i] !== expectedType) {
|
||||||
|
expectedTypeName ??= expectedType;
|
||||||
|
|
||||||
this.#error(
|
this.#error(
|
||||||
`Expected parameter #${
|
`Expected parameter #${
|
||||||
i + 1
|
i + 1
|
||||||
} to be of type ${expectedType}, got ${typeof args[i]}`,
|
} to be of type ${expectedTypeName}, got ${typeof args[i]}`,
|
||||||
func,
|
func,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expectedType instanceof Object && !(args[i] instanceof expectedType)) {
|
if (expectedType instanceof Object && !(args[i] instanceof expectedType)) {
|
||||||
const expectedTypeName = expectedType.prototype.constructor.name;
|
expectedTypeName ??= expectedType.prototype.constructor.name;
|
||||||
|
|
||||||
this.#error(
|
this.#error(
|
||||||
`Expected parameter #${
|
`Expected parameter #${
|
||||||
|
Loading…
x
Reference in New Issue
Block a user