Prolifode/deno_rest

JsonValue Error

Closed this issue · 2 comments

I am trying to run this project in my local machine. Even after following all the instructions in the Readme.md, I am unable to run this app using "denon start" command. I'm getting following error:

error: TS2322 [ERROR]: Type 'string | undefined' is not assignable to type 'JsonValue'.
  Type 'undefined' is not assignable to type 'JsonValue'.
      id,
      ~~
    at file:///D:/Projects/deno_rest/helpers/jwt.helper.ts:30:7

    The expected type comes from this index signature.
      [key: string]: JsonValue;
      ~~~~~~~~~~~~~~~~~~~~~~~~~
        at https://deno.land/x/djwt@v2.6/mod.ts:25:3

This error is caused by the following code in jwt.helper.ts

const payload: Payload = {
  iss: "deno_rest",
  iat: now,
  id, 
  exp,
};

Creating id non-null solves the issue. Should I make pr for the fix?

Creating id non-null solves the issue. Should I make pr for the fix?

Yes thank you for pointing out. non-null id makes more sense. Please go ahead and open a PR.