I'm facing a simple issue that I just can't seem to solve. The npm module next-tick has something like this in its index.js:
module.exports = (function () {
if (/*node*/) {
return process.nextTick;
}
...
if (/*other env*/) {
return function (cb) { setTimeout(callable(cb), 0); };
}
return null;
}());
There are currently no typings available, so I created a next-tick.d.ts and added it to my tsconfig.json.
However, I am struggling with what should be included in the file:
The only thing that I have gotten to work without compiler errors is:
declare module "next-tick" {
export default function(fn: Function)
}
And in the consuming file:
import nextTick from 'next-tick';
But when I bundle with webpack and run it, I get an error saying:
next_tick_1.default is not a function
. It seems to be trying to call .default
.
Another solution that works is using require (and adding declarations for that with webpack typings):
var nextTick: (fn: Function) => void = require('next-tick');
But I believe there should be a way to achieve this with a TypeScript import?