"Overload signatures must all be ambient or non-ambient" when using setTimeout in another function
Asked Answered
F

1

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?

Flense answered 3/9, 2015 at 22:52 Comment(1)
I couldn't reproduce the error, and everything looks fine to me. Is that all of the code?Kuo
Z
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.

Zoolatry answered 11/3, 2019 at 19:34 Comment(1)
I can't check it now but it seems like a plausible answer.Flense

© 2022 - 2024 — McMap. All rights reserved.