Seeking assistance from experienced individuals in the realm of gulp.js and typescript - could someone provide guidance for a struggling newcomer?
I am currently utilizing the most recent versions of all relevant tools (node, ts-node, gulp, ts, @types/gulp, etc). Gulp is being executed through ts-node, using a gulpfile.ts
instead of gulpfile.js
, but I am encountering the following error:
error TS2345: Argument of type 'Promise<void>' is not assignable to parameter of type 'Task'.
Type 'Promise<void>' does not match the signature expected by 'TaskFunction'.
The return type ''Promise<void>'' is incompatible with '(done: TaskCallback): void | EventEmitter | ChildProcess | Stream | Observable<any> | PromiseLike<any>'.
The key portions of my code are as follows:
gulp.parallel(
subTask("directory_1"),
subTask("directory_2")
);
async function subTask(sDirectory:string){
await gulp.src("src/"+sDirectory+"/*.*")
// Perform tasks such as linting, transpiling, uglifying, etc.
.pipe(gulp.dest("dest/"+sDirectory+"/"));
return;
}
The code functions correctly when the directory strings are hardcoded within subTask
(creating separate copies for each directory), however it fails when attempting to pass the directories as parameters.
It appears that the issue lies in returning a void
promise from subTask
whereas gulp expects a type of Task
(a subtype of
TaskFunction</code). Trouble arises when trying to assign a type to <code>subTask
(assigning either Task
or TaskFunction
results in "Cannot find name 'Task'").
What mistake am I making here? And more importantly, how can I resolve it? Can anyone provide example code to rectify this issue?
Your assistance and guidance would be immensely appreciated. Thank you.
Best regards,
Dulux-Oz