Azure-sdk-for-js: @azure/service-bus doesn't tsc transpile

Created on 25 Feb 2019  路  9Comments  路  Source: Azure/azure-sdk-for-js

When I try to use tsc while importing the @azure/service-bus packages I get the following errors:

node_modules/@azure/service-bus/typings/lib/subscriptionClient.d.ts:1:23 - error TS2688: Cannot find type definition file for 'long'.

1 // \
~~~~

node_modules/@azure/service-bus/typings/lib/subscriptionClient.d.ts:76:46 - error TS2304: Cannot find name 'Long'.

76 peekBySequenceNumber(fromSequenceNumber: Long, messageCount?: number): Promise ~~~~

Found 2 errors.

Client Service Bus question

Most helpful comment

Hello, I encountered the same problem and I somewhat fixed it adding esModuleInterop, but this was breaking my project since some imports was using the import * as <library> from '<library>' way.

I manage to solve this adding only allowSyntheticDefaultImports and not esModuleInteropto the tsconfig

All 9 comments

@jeffhollan npm install @types/long should fix this issue. In the meantime, we need to move @types/long to a dependency from a dev dependency to ensure the types get installed properly.

I tried that and the issue persisted with a different error. Will repro tonight and share

@jeffhollan you will probably also need @types/node as well. In any case happy to help debug from whatever error messages you're seeing!

Ok installed both @types/node and @types/long and get this error. Also checked to make sure i had same version -- I'm using"@types/long": "^4.0.0", which seems to match what's in devDependencies of this repo

node_modules/@azure/service-bus/typings/lib/core/managementClient.d.ts:1:8 - error TS1192: Module '"/Users/jeffhollan/Development/GitHub/functions-multiple-queue-exponential/functions-node-queue-exponential/node_modules/@types/long/index"' has no default export.

1 import Long from "long";
~~~~

node_modules/@azure/service-bus/typings/lib/serviceBusMessage.d.ts:2:8 - error TS1192: Module '"/Users/jeffhollan/Development/GitHub/functions-multiple-queue-exponential/functions-node-queue-exponential/node_modules/@types/long/index"' has no default export.

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

Found 2 errors.

@jeffhollan sorry I missed your update! The last issue you point out is because you need to enable esModuleInterop in your tsconfig compiler options. I'll document this in the readme as part of #1338.

Hello, I encountered the same problem and I somewhat fixed it adding esModuleInterop, but this was breaking my project since some imports was using the import * as <library> from '<library>' way.

I manage to solve this adding only allowSyntheticDefaultImports and not esModuleInteropto the tsconfig

@TizioFittizio that's a very good point, allowSyntheticDefaultImports is a likely better choice for existing projects (the TS team does recommend esModuleInterop for new projects. I'll add this to the readme!

Just confirming that when I both manually import @types/long and set allowSyntheticDefaultImports it works

@types/long should come down automatically with npm install and the readme should now be more helpful on this topic. Thanks much for the report!

Was this page helpful?
0 / 5 - 0 ratings