You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have hundreds of warnings when generating my typescript for the "Could not find suitable TypeScript type..." that are all coming from parameters using the [FromServices] attribute. Is there a built-in way for the MethodCodeGenerator.GenerateNode to ignore parameters with that attribute?
The text was updated successfully, but these errors were encountered:
The warning is actually very useful and I don't want to suppress that type of warning outright. I just want to suppress the warnings for parameters that use the [FromServices] attribute since those parameters are completely excluded from our generated typescript.
I implemented a very hacky but working solution in the meantime.
// Use reflection to modify the type resolver's private _resolveCache dictionary to// include the [FromService] parameters so that reinforced types doesn't complain// about not being able to find a suitable type.varfromServicesParams=element.GetParameters().Where(p =>p.GetCustomAttribute(typeof(FromServicesAttribute))!=null).ToList();varresolveCache=typeof(TypeResolver).GetField("_resolveCache",BindingFlags.NonPublic|BindingFlags.Instance);vardict=(Dictionary<Type,RtTypeName>?)resolveCache?.GetValue(resolver);if(dict!=null){foreach(varpinfromServicesParams){dict[p.ParameterType]=newRtSimpleTypeName("any");}}result=base.GenerateNode(element,result,resolver);
First, much love for this project!
I have hundreds of warnings when generating my typescript for the "Could not find suitable TypeScript type..." that are all coming from parameters using the [FromServices] attribute. Is there a built-in way for the
MethodCodeGenerator.GenerateNode
to ignore parameters with that attribute?The text was updated successfully, but these errors were encountered: