elringus / bootsharp

Compile C# solution into single-file ES module with auto-generated JavaScript bindings and type definitions

Home Page:https://bootsharp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support typedefs for nullable collection elements

elringus opened this issue · comments

Currently, we can detect when a property, method argument and method return type is explicitly marked as nullable (either Nullable<> or has ? in nullable context) and generate corresponding TypeScript declaration with either ? or undefined modifier:

https://github.com/Elringus/DotNetJS/blob/456c1b5af62e88dddcc1215767ce2922529d9f52/DotNet/Packer/Utilities/TypeUtilities.cs#L43-L63

However, I'm not sure if it's possible to detect when a collection element type has nullable modifier, eg string?[] or List<string?>. NullabilityInfoContext doesn't seem to have a way to detect that.

If anyone have any idea how to infer nullability of collection and array element types, please let us know here.