Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
deveitrust opened this issue Mar 5, 2020 · 4 comments
Open

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

deveitrust opened this issue Mar 5, 2020 · 4 comments

Comments

@deveitrust
Copy link

deveitrust commented Mar 5, 2020

In documentation:

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

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

@dsherret
Copy link
Owner

dsherret commented Mar 5, 2020

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.

@deveitrust
Copy link
Author

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!

@dsherret
Copy link
Owner

dsherret commented Mar 5, 2020

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>()}>`

@deveitrust
Copy link
Author

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!

@dsherret dsherret changed the title nameof.full<T>() Support nameof.full<Array<T>>() to "Array<T>" Mar 5, 2020
@cecilyth cecilyth removed their assignment Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants