Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type checking error for generate function #80

Closed
2 tasks done
WangHansen opened this issue Apr 26, 2020 · 2 comments
Closed
2 tasks done

Type checking error for generate function #80

WangHansen opened this issue Apr 26, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@WangHansen
Copy link

WangHansen commented Apr 26, 2020

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.
@panva
Copy link
Owner

panva commented Apr 27, 2020

@WangHansen please see the fix-80 branch and let me know if it resolves the issue.

@panva panva added bug Something isn't working waiting for feedback The OP is asked for feedback or a proposal and removed triage labels Apr 27, 2020
@panva panva closed this as completed in 7e60722 Apr 27, 2020
@WangHansen
Copy link
Author

@panva Sorry for the late reply, it works now, thank you for the fast fix. It apparently has something to do with TypeScript itself as well, see this. But with your fix, it should work now, thanks again!

@panva panva removed the waiting for feedback The OP is asked for feedback or a proposal label May 2, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Aug 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants