Node JS typescript compiler not liking Solace API reference to 'long'

ihandley
ihandley Member Posts: 1

I'm running into this error when I try to run my TS compiler:

node_modules/solclientjs/index.d.ts:2:10 - error TS2616: 'Long' can only be imported by using 'import Long = require("long")' or a default import.


2 import { Long } from "long";
           ~~~~


node_modules/solclientjs/index.d.ts:2:22 - error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.


I've tried following the suggestion of toggling the 'esModuleInterop' flag, but it appears like the solclientjs module is simply referencing the 'long' package incorrectly. Any advice for fixing (good) or getting around (not as good) this error?


Thanks in advance. I'm sure this is in the wrong place, but I was only given two wrong categories to post into.

Answers

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 914 admin

    Hi @ihandley,

    Were you able to find a way around this? We have added this to an existing JIRA ticket internally to improve our TS type declarations but it is not yet scheduled to be worked.

  • Kesu
    Kesu Member Posts: 1

    Hi @ihandley and @marc,

    I also encountered this and the problem is that "@types/long" is specified in "devDependencies" in package.json of solclientjs v10.10.0.

    "devDependencies" are only installed when you run "npm install" while developing solclientjs, not when you install solclientjs as a dependency in another project.

    For "@types/long" to be installed together with solclientjs in users projects it must be specified in "dependencies".

    This problem was solved for me after I added "@types/long" as a dependency alongside solclientjs in my project.

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 914 admin

    Hi @Kesu and @ihandley,

    Just an update that this is in work and is planned to be included as part of the next release later this month ;)

    Thank you very much for your feedback!

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 914 admin

    I got another update from the team - seems there was a bit of confusion.

    The changes that will be in the next release re: type definitions will address the following (and this will be in the release notes):

    JavaScript type definitions:
    
    -SDTMapContainer is missing the method `addField`
    
    -Session type definition is too restrictive
    
    -Message type definition is too restrictive
    
    -MessageConsumer#disposed  should be changed to boolean
    
    -MessageConsumerProperties#queueProperties and SessionProperties#publisherProperties` should be changed to optional
    

    However, we can't fix the specific issue mentioned in this thread until it is resolved in the underlying library here: https://github.com/dcodeIO/long.js/issues/109