question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot build v0.28.1

See original GitHub issue
  • OS: Ubuntu
  • Node.js version: 10.15.1
  • npm version: 6.4.1
  • @google-cloud/pubsub version: 0.28.1

Steps to reproduce

In a new project:

  • npm install typescript @google-cloud/pubsub
  • Create a file src/index.ts with content:
import { PubSub } from "@google-cloud/pubsub";

console.log("Hello world!");
  • npx tsc --init
  • Set rootDir and outDir in tsconfig.json.
  • run npx tsc and the console output should give you a typescript error:
~/code/labs/pub-sub (master #)$ npx tsc

node_modules/google-gax/build/src/streaming.d.ts:47:42 - error TS2507: Type '{ default: DuplexifyConstructor; obj(writable?: Writable | undefined, readable?: Readable | undefined, streamOptions?: DuplexOptions | undefined): Duplexify; }' is not a constructor function type.

47 export declare class StreamProxy extends Duplexify {
                                            ~~~~~~~~~
Found 1 error.

I tried to downgrade the pubsub version a bit but it didn’t solve it.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
marcusradellcommented, Mar 13, 2019

I can confirm that it builds with const { PubSub } = require("@google-cloud/pubsub");.

I haven’t run any code yet to try it out, but hopefully this unblocks us from using the latest version.

Well done with the speedy work here! 🥇

From my point of view, you can close the issue unless you want to keep it open to solve the root cause.

3reactions
cdock1029commented, Mar 12, 2019

typescript 3.3.3333

Same error as @marcusnielsen, in gax-nodejs/src/streaming.ts they are doing:

import * as Duplexify from 'duplexify';

export class StreamProxy extends Duplexify {...}

Edit: removing this is not ideal, causes errors importing other modules. Making this change in my tsconfig.json eliminated the build error:

{
- "esModuleInterop": true,
+ "esModuleInterop": false,
}

esModuleInterop:

Emit '__importStar' and '__importDefault' helpers for runtime babel ecosystem
compatibility and enable '--allowSyntheticDefaultImports' for typesystem compatibility.
Requires TypeScript version 2.7 or later.

Seems import * as is discouraged:

https://github.com/Microsoft/TypeScript/pull/19675

Edit

Try this instead of removing esModuleInterop to isolate fix only to this library:

const PubSub = require('@google-cloud/pubsub').PubSub

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redwood v0.28 (is amazing!) - Releases and Upgrade Guides
This release contains recommended code modifications, which are required to use new features such as the Logger. See the “How to Upgrade” ...
Read more >
Image Layer Details - snyk/driftctl:v0.28.1 | Docker Hub
v0.28.1. logo. snyk/driftctl:v0.28.1. Log4Shell CVE not detected. Digest:sha256:56b3e423d8335764432a6dddf7e318a09614a567f5e80272827814b2a346c7b8. OS/ARCH.
Read more >
Go 1.19 just dropped - Development - Syncthing Forum
The current main fails to build on Go 1.19 in my tests with the following error. # github.com/lucas-clemente/quic-go/internal/qtls C:\.
Read more >
Release Notes — lf-releng-global-jjb v0.40.4.dev0+b7c2eb9 ...
Support for the Throttle Plugin is added to JJB jobs so static build servers can restrict the number of concurrent JJB jobs ran...
Read more >
No cached version... available for offline mode. - Stack Overflow
FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'MyApplication2'. > Could not resolve all ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found