opened
urish
username_0
With the current typings, you must write your import as 

    import PromisePool from 'es6-promise-pool';

however, this causes a runtime error in Node.js: 

    TypeError: es6_promise_pool_1.default is not a constructor

This commit changes the supported TypeScript import syntax to 

    import * as PromisePool from 'es6-promise-pool';

which works correctly in Node.js
Fix typings for use inside node.js
issue
created
timdp
username_1
Thanks for contributing!

Is this ultimately caused by [this TypeScript issue](https://github.com/Microsoft/TypeScript/issues/5565)?

In that case, maybe it's also worth mentioning that there's a legacy API with a named export rather than the default one that TypeScript is struggling with. I'm not sure if the compiler will understand it (and you'd need to add typings) but in ES6, this is also possible:

```js
import { PromisePool } from 'es6-promise-pool'
```

I don't want to keep that API around per se because as I said, it's a legacy thing, but it does seem cleaner than `import *`, right? What would be the expected behavior here?

I'm no TypeScript expert though. The typings were contributed by @bcherny. Maybe he wants to weigh in as well?
comment
created
urish
username_0
Hi Tim, thanks for the super quick and thoughtful response. Yes, it seems to be related.

From [examples in the typescript documentation](https://basarat.gitbooks.io/typescript/docs/quick/nodejs.html) (and also [here](https://www.typescriptlang.org/docs/handbook/declaration-files/library-structures.html)), seems like they use the following syntax:

    import PromisePool = require('es6-promise-pool');

However, it seems like the current typings don't play well with this syntax (typescript complains about `Cannot use 'new' with an expression whose type lacks a call or construct signature`), whereas the typings from the PR also makes it happy in this case.

![image](https://user-images.githubusercontent.com/892318/29710194-faf1a8ec-8997-11e7-879c-cf3eda19cb20.png)

I created a super-small demo repo for this, just git clone, npm install, npm start to watch it in in action:

https://github.com/username_0/es6-promise-pool-typescript
comment
created
timdp
username_1
Hmm, I'm curious why it worked for @bcherny then.

We use TypeScript at work though. I'll ask someone on my team next week just to make sure we don't break anything. :slightly_smiling_face:
comment
created
urish
username_0
Awesome, thanks!

Feel free to ping me if anything. And thanks for this awesome library, I recently used it in a project and it was a perfect fit
comment
created
jimthedev
username_2
Hi there, any update to this? Currently seems like for ts/es6/cjs purposes many are switching away from default exports since it just makes things easier.
comment
created
Aankhen
username_3
FWIW, I have the same problem trying to use it with TypeScript and the PR fixed it.
comment
created
urish
username_0
Closing due to inactivity.
comment