Thanks a lot for sharing this @tipsy_dev !
I'm building a library and this could be really useful there. Do you know if/how to add type-safety in the path of the properties via template literals? I mean, not to return undefined but to make the compiler ensure the path is a valid path.
undefined
E.g.
interface User { email?: string; } interface Group { name?: string; creator?: User; }
So if we do:
// compiles GetFieldType<Group, 'creator.email'>; // produces compilation error GetFieldType<Group, 'creator.invalidPath'>;
Is there a way to do this?
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks a lot for sharing this @tipsy_dev !
I'm building a library and this could be really useful there. Do you know if/how to add type-safety in the path of the properties via template literals? I mean, not to return
undefined
but to make the compiler ensure the path is a valid path.E.g.
So if we do:
Is there a way to do this?