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
Is your feature request related to a problem? Please describe.
When I use render, I have to write functions wrapping render to ensure that callers are putting in all of the expected fields for the templates. It would be helpful if the render* functions could be typed like:
exportfunctionrender<TextendsRecord<string,any>>(// <- this could also be `T extends object` to retain the original typingthis: Eta,template: string|TemplateFunction,// template name or template functiondata: T,meta?: {filepath: string}):
so that, if desired, developers can either define the shape or fall back to Record<string, any>.
Describe the solution you'd like
I'd love to be able to define the render function like:
and if the types do not match, allow the compiler to yell at you. The developer would still be in charge of making sure their types and the templates match, but this would go a long way in helping ensure that any template changes are propagated appropriately across all usages in a project.
I'm willing to open a PR. Thank you!
The text was updated successfully, but these errors were encountered:
@ninanator thanks for the suggestion! I agree this would be helpful and will merge if you can open a PR. I think T extends object will likely be best so as not to break typing.
Is your feature request related to a problem? Please describe.
When I use render, I have to write functions wrapping render to ensure that callers are putting in all of the expected fields for the templates. It would be helpful if the
render*
functions could be typed like:so that, if desired, developers can either define the shape or fall back to
Record<string, any>
.Describe the solution you'd like
I'd love to be able to define the render function like:
and if the types do not match, allow the compiler to yell at you. The developer would still be in charge of making sure their types and the templates match, but this would go a long way in helping ensure that any template changes are propagated appropriately across all usages in a project.
I'm willing to open a PR. Thank you!
The text was updated successfully, but these errors were encountered: