lumeland / lume

🔥 Static site generator for Deno 🦕
https://lume.land
MIT License
1.83k stars 83 forks source link

Incorrect typing for `jsx_preact.ts` #403

Closed indifferentghost closed 1 year ago

indifferentghost commented 1 year ago

Version

v1.16.0

Platform

Linux/Firefox

What steps will reproduce the bug?

Utilize renderAsync it always says it returns a string when we can clearly see that's not true.

  renderSync(content: unknown, data: Data = {}): string {
    const element = typeof content === "function"
      ? content(data, this.helpers)
      : content;

    if (element && typeof element === "object") {
      element.toString = () => renderToString(element);
    }

    return element;
  }

What is the expected behavior?

Typescript inference should be enough here.

What do you see instead?

hard typed as a string

Additional Details?

https://github.com/lumeland/lume/blame/master/plugins/jsx_preact.ts#L66-L76

oscarotero commented 1 year ago

Yeah, good catch. renderSync must return a string or an object with the toString() function defined (which is the case here): https://github.com/lumeland/lume/blob/master/core/renderer.ts#L310

I'll fix it.