Hi,
Using the new ServiceStack 10 and the updated dotnet tool v10 or npx we are getting the majority of typescript DTO’s being generated with properties marked as possibly undefined.
Is there a way to get the previous version format?
Thanks
Hi,
Using the new ServiceStack 10 and the updated dotnet tool v10 or npx we are getting the majority of typescript DTO’s being generated with properties marked as possibly undefined.
Is there a way to get the previous version format?
Thanks
Are you using the just released v10.0.2?
Not yet, I’ll give it a try and report back
Definitely a lot better but still a lot more marked than previously.
Numbers now appear the same as the old version but
mostly strings / references to other DTOs and arrays are now being marked.
Do you have nullable enabled? If so please provide your C# DTO and the generated TypeScript DTO.
No, nullable is not enabled in the ServiceModel project.
Current dto has:
Version: 8.90
Tip: To override a DTO option, remove “//” prefix before updating
BaseUrl: https://localhost:5001
//GlobalNamespace:
//MakePropertiesOptional: False
//AddServiceStackTypes: True
//AddResponseStatus: False
//AddImplicitVersion:
//AddDescriptionAsComments: True
//IncludeTypes:
//ExcludeTypes:
//DefaultImports:
*/
You should enable nullable references, we used the major v10 upgrade window before enabling nullable references where going forward it’s assumed nullable references are enabled which are reflected in the generated DTOs.
Languages with nullable annotations like TypeScript will allow you to control it for each type & property:
TypeScriptGenerator.IsPropertyOptional = (ts, type, prop) =>
{
// Custom Impl
//...
// Default Impl
return TypeScriptGenerator.DefaultIsPropertyOptional(ts, type, prop);
};
Ok - I’ll have a look at the results when nullable enabled.
Thanks