cmorten / opine

Minimalist web framework for Deno ported from ExpressJS.
https://github.com/cmorten/opine/blob/main/.github/API/api.md
MIT License
854 stars 43 forks source link

Type incompatibility with Deno 1.20.1 #164

Closed AEtheve closed 2 years ago

AEtheve commented 2 years ago

Issue

Setup:

Details

There is a type incompatibility with Deno 1.20.1 for listenAndServeTls :


error: TS2345 [ERROR]: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
  Type 'undefined' is not assignable to type 'string'.
          await server.listenAndServeTls(options.certFile, options.keyFile);
                                         ~~~~~~~~~~~~~~~~
    at ./src/application.ts
AEtheve commented 2 years ago

I fixed it temporarily by replacing if (isTls) { in application.ts with : if (isTls && typeof options.certFile == "string" && typeof options.keyFile == "string") {

cmorten commented 2 years ago

Yeah seems types just slightly mismatching now.

ListenTlsOptions have all pertinent keys as optional https://doc.deno.land/deno/stable/~/Deno.ListenTlsOptions which is inherited by opine’s HTTPSOptions https://github.com/cmorten/opine/blob/main/src/types.ts#L22 so isTls isn’t quite cutting it anymore.

Think solution would be to adjust HTTPSOptions defined in opine’s types to have the key and cert keys as non-optional.

AEtheve commented 2 years ago

Ok, fine, that's what I thought, thanks.

cawoodm commented 2 years ago

Sorry, what's the fix here? I'm getting this error with opine 2.1.4 AFAIK the latest version.

cmorten commented 2 years ago

@cawoodm what is the error you are seeing? The fix for this issue was to use latest opine on latest deno (deno upgrade).

If you're still facing issues, feel free to raise a new issue with the error you are seeing