Passing in a callback to the task definition function

All we need to do is to pass a callback function to the task definition function as follows:

gulp.task("sync", function (cb) { 
    // We used setTimeout here to illustrate an async operation 
    setTimeout(function () { 
        console.log("Hello Gulp!"); 
        cb(); // note the cb usage here 
    }, 1000); 
}); 

Get Learning TypeScript 2.x - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.