TypeScript and es6 module import
jonahbron opened this issue · 0 comments
jonahbron commented
Not sure exactly why, but doing this doesn't work in TypeScript:
import * as QueryStream from 'pg-query-stream';
const query = new QueryStream('SELECT true', []);
This produces the following errors:
file.ts (1,1): A namespace-style import cannot be called or constructed, and will cause a failure at runtime. (7038)
file.ts (2,14): Cannot use 'new' with an expression whose type lacks a call or construct signature. (2351)
I even tried installing @types/pg-query-stream
, but that didn't help.
But the import method recommended in the README does work in TypeScript, even if the rest of your imports use the es6 style.
const QueryStream = require('pg-query-stream');
const query = new QueryStream('SELECT true', []);