Nullable C# types aren't always correctly mapped to Typescript
Opened this issue · 0 comments
Fasteroid commented
Some nullable types on the C# side aren't correctly mapped to nullable types on the Typescript side. Examples include:
List<T>?
becomesT[ ]
rather thanT[ ] | null
List<T?>
becomesT[ ]
rather than(T | null)[ ]
List<T?>?
becomesT[ ]
rather than(T | null)[ ] | null
I suspect this is a problem unique to IEnumerables due to how they need to end with square brackets in Typescript, opposed to any other type which can be handled "normally".
I have found a workaround for the first case, which for me was all I needed...
bool IsNullable(Property p){
return p.Type.FullName.EndsWith("?");
}
But I'm unsure if that's as easy for the other two cases, or god forbid, lists of lists, which I bet also suffer from this.
Might look into this later if I have time.