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

TypeScript and es6 module import #43

@jonahbron

Description

@jonahbron

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', []);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions