I was able to make a patch at GenerateNode
in PropertyCodeGenerator:
result.Type = type;
//Add this code
if (element.GenericReturnTypeIsNullable())
{
var simpleType = type as RtSimpleTypeName;
var genericArguments = simpleType.GenericArguments.Cast<RtSimpleTypeName>().ToArray();
for (int i = 0; i < genericArguments.Length; i++)
{
var genericArgument = genericArguments[i];
genericArguments[i] = new RtSimpleTypeName(genericArgument.TypeName + " | undefined");
}
result.Type = new RtSimpleTypeName(simpleType.TypeName, genericArguments);
}
This proves what I want to achieve is possible but unfortunately means I will have to make my own version of the library to accommodate this change.
Keep in mind the solution above is not 100% complete as it doesn't check the index of each generic argument, it only assumes if one is nullable then all are :) I leave this as an exercise for the readers...
If there is a better way please let me know so I am not reinventing the wheel.
Thank you!