JamesBroadberry / deno-bcrypt

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

Removing extra worker param #9

Closed Bidek56 closed 4 years ago

Bidek56 commented 4 years ago

I am removing extra worker param which was causing TS2345 errors when using a simple tsconfig.json

{
    "compilerOptions": {
        "lib": [
            "dom",
            "es2017",
            "deno.ns",
            "dom.iterable"
        ]
    }
}

running: deno run -A -c .\tsconfig.json .\crypt.ts deno 1.2.0 v8 8.5.216 typescript 3.9.2

Bidek56 commented 4 years ago

@JamesBroadberry Do you think you can merge this in so I can move my project forward? Thanks

JamesBroadberry commented 4 years ago

Hi @Bidek56, sorry, I've been busy with work so haven't had chance to properly review this.

I've just tried it out without the deno: true flag and it's causing issues because the worker requires access to Deno specific modules. This is because crypto.GetRandomValues is required.

It doesn't seem to cause any issues with my projects using it so if you can create some steps to reproduce and raise an issue, I can take a further look.

Thanks!

Bidek56 commented 4 years ago

Simple: import { hash, compare } from "https://deno.land/x/bcrypt@v0.2.3/mod.ts"; causes:

error: 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.3/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.3/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.3/main.ts:83:23

Found 3 errors.

when running deno run -c .\tsconfig.json .\crypt.ts with:

{
    "compilerOptions": {
        "lib": [
            "dom",
            "es2017",
            "deno.ns",
            "dom.iterable"
        ]
    }
}

If you know the tsconfig.json option that would resolve the error, that would be great. Thx