Deno: Issue running v1.0.0 with [email protected]

Created on 14 May 2020  路  8Comments  路  Source: denoland/deno

I tried Deno today. Congrats on 1.0.0, I wanted to report an issue I ran into at risk of embarrassing myself, it's possible that I just don't know what I'm doing.

I started today with v1.0.0-rc3 and used a few dependencies (fs, path, http) and denon as an installed cli tool. It worked fine.

When v1.0.0 was released I tried running my test application again and ran into a TS error.

error: TS2322 [ERROR]: Type 'string' is not assignable to type 'boolean'.
  return srcArray.reduce(
    at https://deno.land/[email protected]/fs/_util.ts:20:3

I was able to resolve this one of two ways for my project.

1) I could downgrade to v1.0.0-rc3
2) I could use the latest version of std

With some investigating it seems like maybe this changed caused a desync between the runtime and std. https://github.com/denoland/deno/commit/3d7552af2e19f489501f6a1e27f8a4f488ce123a#diff-da37be1ae0975896a3e9d32a5131aeae

In order to get denon working my only option is to downgrade deno to v1.0.0-rc3.

Figure this is fixed with the next release of std, as soon as denon upgrades.

bug

Most helpful comment

@alextes std 0.51.0 has been released.

All 8 comments

This is probably a bug in denon; https://github.com/eliassjogreen/denon/issues/34

I get the same error in my own small test app when I import [email protected]/fs using v1.0.0, and not when using v.1.0.0-rc3.

deps.ts

export { serve } from "https://deno.land/[email protected]/http/server.ts";
export { resolve, join } from "https://deno.land/[email protected]/path/mod.ts";
export { readFileStr } from "https://deno.land/[email protected]/fs/mod.ts";

main.ts

import {
  readFileStr,
  join,
  resolve,
  serve,
} from "./deps.ts";

const server = serve({ port: 3001 });
const publicFolder = resolve("public");

for await (const req of server) {
  if (req.url === "/") {
    const fileContents = await readFileStr(
      join(publicFolder, "index.html"),
      { encoding: "utf8" },
    );
    req.respond({ body: fileContents });
  } else {
    req.respond({
      status: 404,
      body: "Not Found\n",
    });
  }
}

Typescript issue #30821 is commented in the std source so this is probably not an issue with deno nor denon

Could it be the @ts-ignore is on the wrong line?

The issue linked in the https://deno.land/[email protected]/fs/_util.ts source talks about inference showing a false positive (I think). Putting a @ts-ignore and a comment explaining why is the A+ way to deal with it in my book. Yet, an error shows up and blocks the install of Denon and I'm guessing any other package importing this module. Error shows up on line 20, ts-ignore is on line 21.

Went to fix it but noticed it's already fixed in master (3d7552a) 馃帀 .

You people move fast! Thanks @kitsonk 馃檹 .

@alextes std 0.51.0 has been released.

Doesn't work for me with 0.51.0 either:

deno run --allow-net --allow-read index.ts

...results in:

TS2339 [ERROR]: Property 'utime' does not exist on type 'typeof Deno'.
    await Deno.utime(dest, statInfo.atime, statInfo.mtime);
               ~~~~~
    at https://deno.land/[email protected]/fs/copy.ts:90:16

TS2339 [ERROR]: Property 'utimeSync' does not exist on type 'typeof Deno'.
    Deno.utimeSync(dest, statInfo.atime, statInfo.mtime);
         ~~~~~~~~~
    at https://deno.land/[email protected]/fs/copy.ts:101:10

TS2339 [ERROR]: Property 'symlink' does not exist on type 'typeof Deno'.
  await Deno.symlink(originSrcFilePath, dest, type);
             ~~~~~~~
    at https://deno.land/[email protected]/fs/copy.ts:114:14

TS2339 [ERROR]: Property 'utime' does not exist on type 'typeof Deno'.
    await Deno.utime(dest, statInfo.atime, statInfo.mtime);
               ~~~~~
    at https://deno.land/[email protected]/fs/copy.ts:119:16

TS2339 [ERROR]: Property 'symlinkSync' does not exist on type 'typeof Deno'.
  Deno.symlinkSync(originSrcFilePath, dest, type);
       ~~~~~~~~~~~
    at https://deno.land/[email protected]/fs/copy.ts:132:8

TS2339 [ERROR]: Property 'utimeSync' does not exist on type 'typeof Deno'.
    Deno.utimeSync(dest, statInfo.atime, statInfo.mtime);
         ~~~~~~~~~
    at https://deno.land/[email protected]/fs/copy.ts:137:10

TS2339 [ERROR]: Property 'utime' does not exist on type 'typeof Deno'.
    await Deno.utime(dest, srcStatInfo.atime, srcStatInfo.mtime);
               ~~~~~
    at https://deno.land/[email protected]/fs/copy.ts:157:16

TS2339 [ERROR]: Property 'utimeSync' does not exist on type 'typeof Deno'.
    Deno.utimeSync(dest, srcStatInfo.atime, srcStatInfo.mtime);
         ~~~~~~~~~
    at https://deno.land/[email protected]/fs/copy.ts:185:10

TS2339 [ERROR]: Property 'link' does not exist on type 'typeof Deno'.
  await Deno.link(src, dest);
             ~~~~
    at https://deno.land/[email protected]/fs/ensure_link.ts:28:14

TS2339 [ERROR]: Property 'linkSync' does not exist on type 'typeof Deno'.
  Deno.linkSync(src, dest);
       ~~~~~~~~
    at https://deno.land/[email protected]/fs/ensure_link.ts:52:8

TS2339 [ERROR]: Property 'symlink' does not exist on type 'typeof Deno'.
  await Deno.symlink(src, dest, srcFilePathType);
             ~~~~~~~
    at https://deno.land/[email protected]/fs/ensure_symlink.ts:31:14

TS2339 [ERROR]: Property 'symlinkSync' does not exist on type 'typeof Deno'.
  Deno.symlinkSync(src, dest, srcFilePathType);
       ~~~~~~~~~~~
    at https://deno.land/[email protected]/fs/ensure_symlink.ts:58:8

Found 12 errors.

Version (on Windows 10):

> deno --version
deno 1.0.0
v8 8.4.300
typescript 3.9.2

@C0Nd3Mnd use --unstable flag; more info here: https://deno.land/manual/standard_library#troubleshooting

Was this page helpful?
0 / 5 - 0 ratings