jvail / glpk.js

GLPK for browser & node
GNU General Public License v3.0
106 stars 19 forks source link

Using GLPK() in TypeScript results in 'This expression is not callable' #37

Closed domdomegg closed 1 year ago

domdomegg commented 1 year ago

This code in TypeScript

import GLPK from "glpk.js";

const glpk = GLPK();

Throws a compliation error:

This expression is not callable.
  Type 'typeof import("/my_app/node_modules/glpk.js/dist/glpk")' has no call signatures.ts(2349)

However, based on the documentation this seems like the correct way to initialise the library. Using // @ts-ignore, the library seems to work correctly. So I think this is an issue with the typings in dist/glpk.d.ts.

Specifically I'm using versions:

typescript: 4.9.4
glpk.js: 4.0.1

But think it applies on any modern version of TypeScript.

jvail commented 1 year ago

Hello @domdomegg,

I admit my treatment of TS is quite stepmotherly ... If the fix in the PR works for you (I guess it does now?) then I am just going to merge it.

Thank you Jan

domdomegg commented 1 year ago

Hi Jan,

Yes, the fix in my PR works for me.

Adam

laszlojakab commented 10 months ago

Could you please release this fix to npm?

jvail commented 10 months ago

Could you please release this fix to npm?

Yes, good idea. I'll try to get it done over the weekend.