You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exportclassFooimplementsIFoo{dates?: (Date|undefined)[]|undefined;// Correct: Defines dates array as potentially containing undefined elements// ...init(_data?: any){if(_data){if(Array.isArray(_data["dates"])){this.dates=[]asany;for(letitemof_data["dates"])this.dates!.push(newDate(item));// Correct: Initialises (Date | undefined) array with potentially undefined dates at their expected indexes}// ...}// ...toJSON(data?: any){data=typeofdata==='object' ? data : {};if(Array.isArray(this.dates)){data["dates"]=[];for(letitemofthis.dates)data["dates"].push(item.toISOString());// Incorrect: item may be null/undefined and is never checked, toISOString() throws}// ...}}
In my config I want to use the
/NullValue:Undefined
cli option for the generation of a Angular Api Client.This was no real issue before, since I had strict disabled in my tsconfig, but since I changed it we found an issue.
When I use undefined as our nullvalue, object types get a null check.
The issue now is that the string does not get such a check.
And I also think other primitive values suffer from the same fate.
So from the backend I get a null from the api call.

The property is defined with undefined.
But in the assign from the value we are missing the null check.
for objects this happens with a check.
So the desired behaviour would be the same as for an object for primitive types, or something simliar to this:
That way i can be sure the value is undefined and not null.
Since null should not even be allowed from the configuration.
The issue is similar to this discussion.
#926 (comment)
The text was updated successfully, but these errors were encountered: