Pg-promise: Multi-line ts import crashes compile

Created on 4 Oct 2018  路  5Comments  路  Source: vitaly-t/pg-promise

Expected behavior

normal ts/js compilation

Actual behavior

error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof pgPromise' has no compatible call signatures.

Steps to reproduce

run the examples in README, the multiline import with wildcard doesnt compile for me ie:

import pgPromise, {IMain, IDatabase, IOptions } from 'pg-promise'; ---> works
import {IMain, IDatabase, IOptions} from 'pg-promise';
import * as pgPromise from 'pg-promise';   ---> error TS2349

Environment

  • Version of pg-promise: "pg-promise": "^8.4.6"
  • OS type (Linux/Windows/Mac): win & ubuntu
  • Version of Node.js: 8.10
TypeScript

Most helpful comment

Modern TypeScript has so many special options these days, that some of them indeed may result in pg-promise script not transpiling correctly. This however does not merit documenting all such cases.

The important thing is, examples like pg-promise-demo builds correctly, without issues, while relying on the default TypeScript settings, i.e. it builds fully without any tsconfig.json.

If something does not build using the default TypeScript profile, it is worth documenting, otherwise it is not.

All 5 comments

Which version of TypeScript are you using?

ts-node v7.0.1
node v8.12.0
typescript v3.1.1

Do you have esModuleInterop or allowSyntheticDefaultImports set in your typescript compiler options? These options change typescript's import behavior in a way that could cause the behavior you're seeing.

Ok, tested both, @dimfeld is right, esModuleInterop: true doesn't let the tutorials compile properly. The other flag has no influence.
Worth a mention in README?

Modern TypeScript has so many special options these days, that some of them indeed may result in pg-promise script not transpiling correctly. This however does not merit documenting all such cases.

The important thing is, examples like pg-promise-demo builds correctly, without issues, while relying on the default TypeScript settings, i.e. it builds fully without any tsconfig.json.

If something does not build using the default TypeScript profile, it is worth documenting, otherwise it is not.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

normanfeltz picture normanfeltz  路  4Comments

calibermind picture calibermind  路  3Comments

paleite picture paleite  路  4Comments

cortopy picture cortopy  路  5Comments

hawkeye64 picture hawkeye64  路  4Comments