eta-dev / eta

Embedded JS template engine for Node, Deno, and the browser. Lighweight, fast, and pluggable. Written in TypeScript
https://eta.js.org
MIT License
1.41k stars 65 forks source link

Improve `render` functions return types #189

Closed art049 closed 1 year ago

art049 commented 2 years ago

Hey, thanks a lot for this library!

Is your feature request related to a problem? Please describe. When using the lib with typescript, calling render will return the union string | Promise<string> | void whatever the call arguments are. This is painful as using the library results always results in an unnecessary cast:

const rendered = Eta.render(template, {}) as string

From what I see in the code, the same problem applies to renderAsync, renderFile and renderFileAsync

Describe the solution you'd like It should be possible to overload the function types to allow better-returned types

shadowtime2000 commented 1 year ago

Will look more into this 👍