Skip to content

Type checking error for generate function #80

@WangHansen

Description

@WangHansen

Describe the bug

TypeScript error: Argument of type '"string"' is not assignable to parameter of type '"oct"'

To Reproduce

Steps to reproduce the behaviour:

  1. create a keystore with new jose.JWT.KeyStore()
  2. create a type alias type Algorithm = "RSA" | "EC" | "OKP" | "oct";
  3. create a function generateKey:
function generateKey(alg: Algorithm) {
  return keystore.generateSync(alg, "P-256");
}

Reproduction link: https://codesandbox.io/s/laughing-shockley-hlpr1?file=/src/index.ts

Expected behaviour
Expect no error with type checking

Environment:

  • jose version: v1.26.0
  • node version: v12.13.1

Additional context
Add any other context about the problem here.

  • the bug is happening on latest jose too.
  • i have searched the issues tracker on github for similar issues and couldn't find anything related.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions