Skip to content

Commit

Permalink
fix(model): improved logging for partial models
Browse files Browse the repository at this point in the history
  • Loading branch information
ProGM committed Jan 25, 2025
1 parent d661c58 commit f597ebd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions dist/index.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,13 @@ class Parser {
if (loadedElement.$_partial) {
return new Proxy(instance, {
get: function (target, prop) {
if (prop in target) {
return target[prop];
}
if (prop === "$_partial") {
return true;
}
if (prop in target) {
debug('warn', `Trying to call property ${prop.toString()} to a model that is not included ("${loadedElement.type}"). Maybe you mean't to include it?`);
return target[prop];
}
debug('error', `Trying to call property "${prop.toString()}" to a model that is not included. Add "${loadedElement.type}" to included models.`);
return undefined;
}
Expand Down
7 changes: 4 additions & 3 deletions dist/index.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,13 @@ class Parser {
if (loadedElement.$_partial) {
return new Proxy(instance, {
get: function (target, prop) {
if (prop in target) {
return target[prop];
}
if (prop === "$_partial") {
return true;
}
if (prop in target) {
debug('warn', `Trying to call property ${prop.toString()} to a model that is not included ("${loadedElement.type}"). Maybe you mean't to include it?`);
return target[prop];
}
debug('error', `Trying to call property "${prop.toString()}" to a model that is not included. Add "${loadedElement.type}" to included models.`);
return undefined;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,13 @@ export class Parser {
instance,
{
get: function<T extends object>(target: T, prop: keyof T) {
if (prop in target) {
return target[prop];
}
if (prop === "$_partial") {
return true;
}
if (prop in target) {
debug('warn', `Trying to call property ${prop.toString()} to a model that is not included ("${loadedElement.type}"). Maybe you mean't to include it?`);
return target[prop];
}
debug('error', `Trying to call property "${prop.toString()}" to a model that is not included. Add "${loadedElement.type}" to included models.`);
return undefined;
},
Expand Down

0 comments on commit f597ebd

Please sign in to comment.