node-modules / agentkeepalive

Support keepalive http agent.
MIT License
579 stars 57 forks source link

TypeScript import not clear/broken? #76

Closed brandonros closed 4 years ago

brandonros commented 5 years ago
import { default as HttpAgent } from 'agentkeepalive'
import * as HttpAgent from 'agentkeepalive'
import HttpAgent from 'agentkeepalive'
import HttpAgent = require('agentkeepalive')

None of these work.

> new HttpAgent()
[eval].ts:2
new agentkeepalive_1.default();
^

TypeError: agentkeepalive_1.default is not a constructor
    at [eval].ts:2:1
Cannot use 'new' with an expression whose type lacks a call or construct signature.

3 new HttpAgent()
dpoetzschke commented 5 years ago

I am getting the same error on our TypeScript project. When using the suggested changes to the d.ts and change the import to * as TypeScript compiles correctly to new AgentLeepAlive(this.httpKeepAliveConfig); instead of the new AgentLeepAlive.default(this.httpKeepAliveConfig);

sean-krail commented 4 years ago

Hey @fengmk2, just a friendly ping that this issue is blocking our team from using this package with TypeScript.

gunzip commented 4 years ago

same here, the proposed patch seems to fix the issue