Skip to content
This repository has been archived by the owner on Dec 27, 2019. It is now read-only.

TypeScript and es6 module import #43

Open
jonahbron opened this issue Mar 27, 2018 · 0 comments
Open

TypeScript and es6 module import #43

jonahbron opened this issue Mar 27, 2018 · 0 comments

Comments

@jonahbron
Copy link

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', []);
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant