sholladay / pogo

Server framework for Deno

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TS errors coming from pogo using hello world example

damusix opened this issue · comments

mod.ts

import pogo from 'https://deno.land/x/pogo/main.js';

const server = pogo.server({ port : 3000 });

server.router.get('/', () => {
    return 'Hello, world!';
});

server.start();

deno mod.ts output:

➜  trypogo deno mod.ts    
Compile https://deno.land/std@v0.33.0/http/cookie.ts
error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
  Type 'undefined' is not assignable to type 'number'.

► https://deno.land/std@v0.33.0/http/cookie.ts:48:24

48   if (Number.isInteger(cookie.maxAge)) {
                          ~~~~~~~~~~~~~

error TS2532: Object is possibly 'undefined'.

► https://deno.land/std@v0.33.0/http/cookie.ts:49:12

49     assert(cookie.maxAge > 0, "Max-Age must be an integer superior to 0");
              ~~~~~~~~~~~~~

error TS2454: Variable 'req' is used before being assigned.

► https://deno.land/std@v0.33.0/http/server.ts:467:9

467     if (req === Deno.EOF) {
            ~~~

error TS2454: Variable 'req' is used before being assigned.

► https://deno.land/std@v0.33.0/http/server.ts:469:23

469     } else if (err && req) {
                          ~~~

error TS2454: Variable 'slice' is used before being assigned.

► https://deno.land/std@v0.33.0/io/bufio.ts:348:23

348         err.partial = slice;
                          ~~~~~

error TS2454: Variable 'code' is used before being assigned.

► https://deno.land/std@v0.33.0/path/utils.ts:52:30

52     else if (isPathSeparator(code)) break;
                                ~~~~

error TS2454: Variable 'firstPart' is used before being assigned.

► https://deno.land/std@v0.33.0/path/win32.ts:333:10

333   assert(firstPart != null);
             ~~~~~~~~~

error TS2454: Variable 'line' is used before being assigned.

► https://deno.land/std@v0.33.0/textproto/mod.ts:85:52

85         `malformed MIME header initial line: ${str(line)}`
                                                      ~~~~

error TS2454: Variable 'line' is used before being assigned.

► https://deno.land/std@v0.33.0/textproto/mod.ts:145:12

145       if (!line && !more) {
               ~~~~


Found 9 errors.

Deno version:

➜  trypogo deno --version
deno 0.34.0
v8 8.1.108
typescript 3.7.2

I cannot start my app :/

Pogo is currently tested against Deno 0.33. I haven't yet tried 0.34. You could see if downgrading helps.

These errors look really suspicious, as they are errors coming from Deno's std library, not Pogo itself. It's hard to believe that output is correct. I'm wondering if there could be a caching issue here or maybe you have some custom TS config that is getting in the way

Fixed by 2d7a3c4.

From what I can tell, Deno's std library had a bad release. Updating to the latest fixed it. Should still be compatible with Deno 0.34 (and maybe earlier as well). The issue only affected TypeScript users. JavaScript programs were unaffected.

If you are importing Pogo without an explicit version in the URL, be sure to use Deno's --reload flag to download fresh dependencies.