Skip to content

Generalize type for html in ServerResults typescript definition#385

Open
cdebotton wants to merge 1 commit intothreepointone:masterfrom
cdebotton:server-types
Open

Generalize type for html in ServerResults typescript definition#385
cdebotton wants to merge 1 commit intothreepointone:masterfrom
cdebotton:server-types

Conversation

@cdebotton
Copy link

Since ReactDOM can now render to a readable stream, this will let us properly return that as the type for the HTML value.

ie)

    const { html, css } = renderStatic(() => renderToNodeStream(app));

    ctx.respond = false;
    ctx.status = 200;
    ctx.res.write(
      '<!doctype html>' +
        '<html lang="en">' +
        '<head>' +
        `<style>${css}</style>` +
        '</head>' +
        '<body>' +
        '<main id="app">',
    );

    html
      .on('end', () => {
        ctx.res.end(
          '</main>' +
            '</body>' +
            '</html>',
        );
      })
      .pipe(ctx.res);
  };

Since ReactDOM can now render to a readable stream, this will let us properly return that as the type for the HTML value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant