padarom / guacamole-common-js

:avocado: The JavaScript Guacamole client library modified for easy installation and usage via npm
http://guac-dev.org/
Apache License 2.0
41 stars 18 forks source link

Definition type generate an error in strict mode #19

Closed continif closed 1 year ago

continif commented 1 year ago

Hi Christopher, i'm building an app with your package, and i need to use React.StrictMode, when i create the tunnel this happen:

ERROR in src/components/MyTerminal.tsx:14:80
TS2345: Argument of type '{ 'X-PAM-Compute-UUID': any; }' is not assignable to parameter of type 'boolean | undefined'.
    12 |         console.log(props)
    13 |         var guac = new Guacamole.Client(
  > 14 |             new Guacamole.HTTPTunnel('https://myserver/tunnel', false, {'X-PAM-Compute-UUID': props.terminalId })
       |                                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    15 |             
    16 |         );
    17 |

That's strange because in nostrict mode it works fine, so i went to the class definition and i found that in HTTPTunnels.d.ts the constructor is defined as: constructor(tunnelURL: string, crossDomain?: boolean, extraTunnelHeaders?: boolean); instead of (for example): constructor(tunnelURL: string, crossDomain?: boolean, extraTunnelHeaders?: any);

Pls, could you solve? Thanks in advance.

linn-gith commented 1 year ago

This type issue comes from the custom types hosted in the DefinitelyTyped repo.

I just submitted a PR (https://github.com/DefinitelyTyped/DefinitelyTyped/pull/62543) there which fixes this issue. It might take a couple of days before it gets accepted though.

Talent30 commented 1 year ago

Hey, thanks. I just approved it. Should be merged soon.

continif commented 1 year ago

Thanks so much guys!

padarom commented 1 year ago

The new types are available on npm as @types/guacamole-common-js@1.3.2. Thanks @linn-gith and @Talent30!