7

I have a setTimeout callback but when i put this inside another function, I'm getting an error with tsc:

function delayedSnapshot() {

    setTimeout( function() {
        var filename = "/Users/dc/dump/heapdump.heapsnapshot";
        heapdump.writeSnapshot(function(err, filename) {
          console.log("dump written to", filename);
        });
        process.exit(1);

    }, 5000);

}

>> error TS2384: Overload signatures must all be ambient or non-ambient.

If i remove the outer wrapping delayedSnapshot it will compile fine however. I found something here on what ambient means but it doesn't seem relevant.

http://www.typescriptlang.org/Handbook#modules-working-with-other-javascript-libraries

can someone explain how I stop this error from happening but still keep my wrapper to control the callback firing or not?

user2864740
  • 60,010
  • 15
  • 145
  • 220
dcsan
  • 11,333
  • 15
  • 77
  • 118

1 Answers1

3

Change the function name from delayedSnapshot() to something else.

There seems to be a delayedSnapshot() method defined/declared somewhere else, which is being overloaded here.

Grant Foster
  • 722
  • 2
  • 11
  • 21
Yash
  • 51
  • 5