JamesBroadberry / deno-bcrypt

A port of jBCrypt to TypeScript for use as a Deno module
ISC License
67 stars 5 forks source link

Import fails in Deno v1.7.x #13

Closed Schoude closed 3 years ago

Schoude commented 3 years ago

Version Info:

deno 1.7.4 (release, x86_64-pc-windows-msvc)
v8 9.0.123
typescript 4.1.4

I tried importing the module in Deno v1.7.3/v1.7.4 but I get this error.

> const bcrypt = await import("https://deno.land/x/bcrypt@v0.2.4/mod.ts")
Check https://deno.land/x/bcrypt@v0.2.4/mod.ts
Uncaught TypeError: TS2345 [ERROR]: Argument of type '{ type: "module"; deno: boolean; }' is not assignable to parameter of type 'WorkerOptions'.
  Object literal may only specify known properties, and 'deno' does not exist in type 'WorkerOptions'.
    { type: "module", deno: true },
                      ~~~~~~~~~~
    at https://deno.land/x/bcrypt@v0.2.4/src/main.ts:18:23

TS2345 [ERROR]: Argument of type '{ type: "module"; deno: boolean; }' is not assignable to parameter of type 'WorkerOptions'.
  Object literal may only specify known properties, and 'deno' does not exist in type 'WorkerOptions'.
    { type: "module", deno: true },
                      ~~~~~~~~~~
    at https://deno.land/x/bcrypt@v0.2.4/src/main.ts:50:23

TS2345 [ERROR]: Argument of type '{ type: "module"; deno: boolean; }' is not assignable to parameter of type 'WorkerOptions'.
  Object literal may only specify known properties, and 'deno' does not exist in type 'WorkerOptions'.
    { type: "module", deno: true },
                      ~~~~~~~~~~
    at https://deno.land/x/bcrypt@v0.2.4/src/main.ts:83:23

This also occurs when importing into a module and not only in the Deno REPL.

Maybe you can look into it thanks!

ilsubyeega commented 3 years ago

add --unstable flag to deno references: https://github.com/denoland/deno/blob/master/docs/runtime/workers.md -> https://github.com/denoland/deno/blob/bc7817e1610faf0abe3c8629fc8163fdcb36b75f/docs/runtime/stability.md

Schoude commented 3 years ago

Above solution works! @ilsubyeega 알려줘셔서 감사합니다. 😄

JamesBroadberry commented 3 years ago

Sorry I forgot to reply earlier, I missed the initial notification!

Glad it's sorted and thanks for stepping in! @ilsubyeega

It's also noted in the readme that you'll need the --unstable flag when using async methods but is easy to miss.

Ivan-Kouznetsov commented 3 years ago

It's also noted in the readme that you'll need the --unstable flag when using async methods but is easy to miss.

This error happens when you import the library irrespective of whether you use Async methods