gulpfile.js中的typescript错误

时间:2018-04-17 19:26:21

标签: javascript typescript sass gulp

我正在使用visual studio代码,它内置了类型脚本,它在这段代码中显示了3个错误:

var gulp        = require('gulp');
var browserSync = require('browser-sync').create();
var sass        = require('gulp-sass');

// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
    return gulp.src(['node_modules/bootstrap/scss/bootstrap.scss', 'src/scss/*.scss'])
        .pipe(sass())
        .pipe(gulp.dest("src/css"))
        .pipe(browserSync.stream());
});

// Move the javascript files into our /src/js folder
gulp.task('js', function() {
    return gulp.src(['node_modules/bootstrap/dist/js/bootstrap.min.js', 'node_modules/jquery/dist/jquery.min.js', 'node_modules/popper.js/dist/umd/popper.min.js'])
        .pipe(gulp.dest("src/js"))
        .pipe(browserSync.stream());
});

// Static Server + watching scss/html files

gulp.task('serve', ['sass'], function() {

    browserSync.init({
        server: "./src"  
    });


    gulp.watch(['node_modules/bootstrap/scss/bootstrap.scss', 'src/scss/*.scss'], ['sass']);
    gulp.watch("src/*.html").on('change', browserSync.reload);
});


gulp.task('default', ['js','serve']); 

这些是我得到的错误:

Expected 1-2 arguments, but got 3.
Type 'string[]' has no properties in common with type 'WatchOptions'.
Argument of type 'string[]' is not assignable to parameter of type 'TaskFunction'.
  Type 'string[]' provides no match for the signature '(done: (error?: any) => void): any'.

这些是我的依赖:

"devDependencies": {
    "browser-sync": "^2.23.6",
    "gulp": "^3.9.1",
    "gulp-sass": "^4.0.1",
    "gulp-typescript": "^4.0.2"
  }
}

我无法想象它们是什么造成的,如果我忽略它们,gulp就会运行。但我认为某些事情会崩溃或无法正常工作?任何帮助都会很棒!

0 个答案:

没有答案