Search code examples
javascriptgulp

Gulp: 'function ()' is not assignable to parameter


const gulp = require("gulp");

gulp.task("default", function () {
  console.log("Gulp: 'default' has launched.")
});

In this code, I got a warning message "function (): Argument type Function is not assignable to parameter type Undertaker.TaskFunction" in WebStorm.

The paramters of task() are taskName and fn. fn takes 'task function'. I can't understand why WebStorm mark function () as unassignable argument. A lot of people seem to use function () like that...


Solution

  • You need to remove the global type references for gulp. Your IDE should use node_modules/gulp for type referencing.

    Go to Settings >> Languages & Frameworks >> JavaScript >> Libraries. In there you'll see @types/gulp. Un-tick it to disable it. Now your IDE will use node_modueles/gulp for type reference.