Skip to content

Commit f597ebd

Browse files
committed
fix(model): improved logging for partial models
1 parent d661c58 commit f597ebd

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

dist/index.cjs.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,13 @@ class Parser {
136136
if (loadedElement.$_partial) {
137137
return new Proxy(instance, {
138138
get: function (target, prop) {
139-
if (prop in target) {
140-
return target[prop];
141-
}
142139
if (prop === "$_partial") {
143140
return true;
144141
}
142+
if (prop in target) {
143+
debug('warn', `Trying to call property ${prop.toString()} to a model that is not included ("${loadedElement.type}"). Maybe you mean't to include it?`);
144+
return target[prop];
145+
}
145146
debug('error', `Trying to call property "${prop.toString()}" to a model that is not included. Add "${loadedElement.type}" to included models.`);
146147
return undefined;
147148
}

dist/index.esm.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,13 @@ class Parser {
132132
if (loadedElement.$_partial) {
133133
return new Proxy(instance, {
134134
get: function (target, prop) {
135-
if (prop in target) {
136-
return target[prop];
137-
}
138135
if (prop === "$_partial") {
139136
return true;
140137
}
138+
if (prop in target) {
139+
debug('warn', `Trying to call property ${prop.toString()} to a model that is not included ("${loadedElement.type}"). Maybe you mean't to include it?`);
140+
return target[prop];
141+
}
141142
debug('error', `Trying to call property "${prop.toString()}" to a model that is not included. Add "${loadedElement.type}" to included models.`);
142143
return undefined;
143144
}

src/Parser.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,13 @@ export class Parser {
9191
instance,
9292
{
9393
get: function<T extends object>(target: T, prop: keyof T) {
94-
if (prop in target) {
95-
return target[prop];
96-
}
9794
if (prop === "$_partial") {
9895
return true;
9996
}
97+
if (prop in target) {
98+
debug('warn', `Trying to call property ${prop.toString()} to a model that is not included ("${loadedElement.type}"). Maybe you mean't to include it?`);
99+
return target[prop];
100+
}
100101
debug('error', `Trying to call property "${prop.toString()}" to a model that is not included. Add "${loadedElement.type}" to included models.`);
101102
return undefined;
102103
},

0 commit comments

Comments
 (0)