In @ types / vinyl , the 'File' interface is defined without a module or namespace:

declare let File: FileConstructor; interface File { ... } 

In the following gulp-task, written in TypeScript, I try to process the vynil file, but TypeScript produces as many as 4 error messages:

 return gulp.src(globSelection) .pipe(gulpPlugins.pug()) .pipe(gulp.dest( (file: File) => { console.log(file); return ''; })); 

enter image description here

 Error:(25, 26) TS2345: Argument of type '(file: File) => string' is not assignable to parameter of type '(file: File) => string'. Types of parameters 'file' and 'file' are incompatible. Type 'File' is not assignable to type 'File'. Two different types with this name exist, but they are unrelated. Property 'lastModified' is missing in type 'File'. 

Two different types with this name exist, but they are unrelated. - Only common words that do not indicate which type is needed. And if you look at @types/vynil-fs - everything is annotated exactly like this:

 export function dest(getFolderPath: (file: File) => string): NodeJS.ReadWriteStream; 

How should annotate callback in gulp.dest ?

  • you can simply not specify the type, it is autodetected by the compiler and your IDE - overthesanity

1 answer 1

gulp.dest is waiting for a function that accepts File from the vinyl module, and you are trying to pass it a function that accepts File from some other module.

Check carefully what you have imported and make the File identifier imported from the correct module:

 import * as File from 'vinyl'; 
  • Thank you for your reply! Unfortunately, I still can’t verify its performance, because as soon as I fixed this error, many others arose, because the correction of these errors will take some time. - Bokov Gleb
  • Could finally check your solution. I do not know why you were minus, but it works. Thanks again for your reply! - Side Gleb