Disallow primitive singular registration (#3077)

This commit is contained in:
Jaco Greeff
2021-01-19 22:46:29 +01:00
committed by GitHub
parent c982505f73
commit 1530e55f9d
2 changed files with 9 additions and 1 deletions
+3
View File
@@ -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);