ts-nameof icon indicating copy to clipboard operation
ts-nameof copied to clipboard

Support nameof.full<Array<T>>() to "Array<T>"

Open deveitrust opened this issue 5 years ago • 4 comments

In documentation:

nameof.full<Array<MyInterface>>(); Transforms to: "Array";

How can i get it work and transform into: "Array<MyInterface>" ?

deveitrust avatar Mar 05 '20 16:03 deveitrust

Need to think about this more, but right now the only way to do it is to do:

`${nameof(Array)}<${nameof(MyInterface)}>`

The reason this isn't done by default is because c# doesn't do this with nameof.


Basically whatever solution is chosen need to ensure there's still a way to not include type arguments.

dsherret avatar Mar 05 '20 16:03 dsherret

Need to think about this more, but right now the only way to do it is to do:

`${nameof(Array)}<${nameof(MyInterface)}>`

The reason this isn't done by default is because c# doesn't do this with nameof.

Thank you for the fast response, actually your solution will work but with some improvement (because Array is generic interface it require parameter to be passed like: ${nameof(Array<void>)}<${nameof(MyInterface)}>

In anyway it is not elegant way to make it work, so hope you will add new feature, it will help a lot. Thank you!

deveitrust avatar Mar 05 '20 16:03 deveitrust

No problem! Yeah, maybe something like nameof.fullWithArgs<Array<MyInterface>>()?

Ooops.. you're right. I messed up that example in other ways too. Should be:

`${nameof<Array<void>>()}<${nameof<MyInterface>()}>`

dsherret avatar Mar 05 '20 16:03 dsherret

No problem! Yeah, maybe something like nameof.fullWithArgs<Array<MyInterface>>()?

Ooops.. you're right. I messed up that example in other ways too. Should be:

`${nameof<Array<void>>()}<${nameof<MyInterface>()}>`

Yes please, it would be great, and will save tons of time and help to write elegant ts code. If it is not possible to extend nameof.full functionality to support arguments, then you could create separate function like nameof.fullWithArgs<Array<MyInterface>>() or nameof.all<Array<MyInterface>>() or nameof.complete<Array<MyInterface>>() or with any other naming.

Thank you!

deveitrust avatar Mar 05 '20 16:03 deveitrust