AdaskoTheBeAsT / Typewriter

Automatic TypeScript template generation from C# source files
http://frhagn.github.io/Typewriter
Apache License 2.0
66 stars 13 forks source link

Nullable C# types aren't always correctly mapped to Typescript #47

Open Fasteroid opened 3 months ago

Fasteroid commented 3 months ago

Some nullable types on the C# side aren't correctly mapped to nullable types on the Typescript side. Examples include:

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.