keroxp/servest

Servest doesn't work in deno 1.9.0 ?

Closed this issue · 2 comments

I tried this code in deno 1.9.0.

// @deno-types="https://deno.land/x/servest/types/react/index.d.ts"
import React from "https://dev.jspm.io/react/index.js";
// @deno-types="https://deno.land/x/servest/types/react-dom/server/index.d.ts"
import ReactDOMServer from "https://dev.jspm.io/react-dom/server.js";
import { createApp } from "https://deno.land/x/servest/mod.ts";

const app = createApp();
app.handle("/", async (req) => {
  await req.respond({
    status: 200,
    headers: new Headers({
      "content-type": "text/html; charset=UTF-8",
    }),
    body: ReactDOMServer.renderToString(
      <html>
        <head>
          <meta charSet="utf-8" />
          <title>servest</title>
        </head>
        <body>Hello Servest!</body>
      </html>,
    ),
  });
});
app.listen({ port: 8888 });

Just error printed.

error: TS2729 [ERROR]: Property 'boundary' is used before its initialization.
  readonly newLineDashBoundary = encoder.encode(`\r\n--${this.boundary}`);
                                                              ~~~~~~~~
    at https://deno.land/std@0.90.0/mime/multipart.ts:264:63

    'boundary' is declared here.
      constructor(reader: Deno.Reader, private boundary: string) {
                                       ~~~~~~~~~~~~~~~~~~~~~~~~
        at https://deno.land/std@0.90.0/mime/multipart.ts:269:36

TS2729 [ERROR]: Property 'boundary' is used before its initialization.
  readonly dashBoundaryDash = encoder.encode(`--${this.boundary}--`);
                                                       ~~~~~~~~
    at https://deno.land/std@0.90.0/mime/multipart.ts:265:56

    'boundary' is declared here.
      constructor(reader: Deno.Reader, private boundary: string) {
                                       ~~~~~~~~~~~~~~~~~~~~~~~~
        at https://deno.land/std@0.90.0/mime/multipart.ts:269:36

TS2729 [ERROR]: Property 'boundary' is used before its initialization.
  readonly dashBoundary = encoder.encode(`--${this.boundary}`);
                                                   ~~~~~~~~
    at https://deno.land/std@0.90.0/mime/multipart.ts:266:52

    'boundary' is declared here.
      constructor(reader: Deno.Reader, private boundary: string) {
                                       ~~~~~~~~~~~~~~~~~~~~~~~~
        at https://deno.land/std@0.90.0/mime/multipart.ts:269:36

Found 3 errors.

Running with --no-check parameter looks normal, but in fact you got empty response.

Note: #145

$ curl localhost:8888
curl: (52) Empty reply from server

In deno 1.8.3, worked fine.

$ curl localhost:8888
<html data-reactroot=""><head><meta charSet="utf-8"/><title>servest</title></head><body>Hello Servest!</body></html>%

@gamoutatsumi Oops, it seems to come from tsc's upgrade. I hope bumping std's version resolves the issue...

That works!
Thanks!