79727742

Date: 2025-08-06 19:07:57
Score: 2
Natty:
Report link

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!

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • RegEx Blacklisted phrase (2.5): please let me know
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • High reputation (-1):
Posted by: Jay