Closed pepone closed 4 years ago
The plugin exposes a stream with JavaScript files (.js
) and a stream with declaration files (.d.ts
). You can use this to write the javascript and declaration files to different directories:
var gulp = require('gulp');
var ts = require('gulp-typescript');
var merge = require('merge2'); // Requires separate installation
gulp.task('scripts', function() {
var tsResult = gulp.src('lib/**/*.ts')
.pipe(ts({
declaration: true
}));
return merge([
tsResult.dts.pipe(gulp.dest('release/definitions')),
tsResult.js.pipe(gulp.dest('release/js'))
]);
});
I have no experience with pump
, so that might not work well together.
I see what you say but I think my use case is different, slice2js is generating both JavaScript and TypeScript declarations and putting them in the gulp stream, I was trying to get the TS compiler to use the declarations directly from the gulp stream without need writing them to disk
So that imports in Client.ts
can be resolve to files in the gulp stream rather than to files from disk
I see, I think gulp-filter provides the functionality you need. gulp-typescript reads the files from the input stream, which is usually gulp.src
or tsProject.src()
, but may also be something more complicated as for instance gulp-filter and slice2js.
Is there an option to read the declarations from the stream?
I have a setup like this