Disallow primitive singular registration (#3077)
This commit is contained in:
@@ -316,6 +316,7 @@ export class TypeRegistry implements Registry {
|
||||
this.#classes.set(arg1.name, arg1);
|
||||
} else if (isString(arg1)) {
|
||||
assert(isFunction(arg2), `Expected class definition passed to '${arg1}' registration`);
|
||||
assert(arg1 !== arg2.toString(), `Unable to register circular ${arg1} === ${arg1}`);
|
||||
|
||||
this.#classes.set(arg1, arg2);
|
||||
} else {
|
||||
@@ -333,6 +334,8 @@ export class TypeRegistry implements Registry {
|
||||
? type
|
||||
: JSON.stringify(type);
|
||||
|
||||
assert(name !== def, `Unable to register circular ${name} === ${def}`);
|
||||
|
||||
// we already have this type, remove the classes registered for it
|
||||
if (this.#classes.has(name)) {
|
||||
this.#classes.delete(name);
|
||||
|
||||
Reference in New Issue
Block a user