--allowbool option for tsc command. (version 0.9.1.1)
options.allowimportmodule
Type: Boolean
Default: false
--allowimportmodule option for tsc command. (version 0.9.1.1)
options.declaration
Type: Boolean
Default: false
--declaration option for tsc command.
Generated .d.ts file is also piped into the stream.
Notice: If your output files are NOT going to {working directory}/something/ (to a directory beneath the working directory), you have to tell your output path to gulp-tsc by outDir option for correct reference paths. See Path modification for details.
options.noImplicitAny
Type: Boolean
Default: false
--noImplicitAny option for tsc command.
options.noResolve
Type: Boolean
Default: false
--noResolve option for tsc command.
options.removeComments
Type: Boolean
Default: false
--removeComments option for tsc command.
options.sourcemap
Type: Boolean
Default: false
--sourcemap option for tsc command.
Generated .js.map file is also piped into the stream.
Notice: If your output files are NOT going to {working directory}/something/ (to a directory beneath the working directory), you have to tell your output path to gulp-tsc by outDir option or sourceRoot option. See Path modification for details.
options.tmpDir
Type: String
Default: '' (current working directory)
A path relative to current working directory, where a temporary build folder will be put in.
Notice: If you use this option with sourcemaps, consider to specify outDir or sourceRoot. See options.sourcemap for details.
If you are watching some files in current working directory with gulp.watch(), the creation of temporary build folder will trigger a folder change event.
If this is unexpected, you can put temp folders in a non-watched directory with this option.
A path filter function will receive following two arguments:
String: A relative path to a compiled file.
vinyl.File: A vinyl.File object of a compiled file.
A path filter function can return Boolean, String, vinyl.File or undefined.
Returned value
Effect
true, undefined
Use the file as-is.
false
Skip the file. (not piped into output gulp stream)
String
Replace the file's path with the returned string.
vinyl.File
Use the returned vinyl.File instead.
options.safe
Type: Boolean
Default: false
By default, gulp-tsc ignores warnings from tsc command and emits compiled js files to the gulp stream anyway.
If set this option to true, gulp-tsc never emits compiled files when tsc command returned warnings or errors.
Error handling
If gulp-tsc fails to compile files, it emits error event with gutil.PluginError as the manner of gulp plugins.
This causes gulp to stop running on TypeScript compile errors, which is sometimes a problem like using with gulp.watch().
If you want to suppress the error, just pass { emitError: false } to gulp-tsc like below.
var typescript = require('gulp-tsc');
gulp.task('default', function () {
gulp.watch('src/**/*.ts', ['compile'])
});
gulp.task('compile', function () {
return gulp.src('src/**/*.ts')
.pipe(typescript({ emitError: false }))
.pipe(gulp.dest('dest/'));
});
Path modification
gulp-tsc does some modification to output files to correct relative paths in sourcemap files (.js.map) and declaration files (.d.ts).
However, gulp-tsc doesn't know where your output files are going to be stored finally since it is specified by gulp.dest and gulp-tsc cannot access to it. So gulp-tsc assumes that your output files go into {working directory}/something/ by default.
If your output files are not going there, you have to tell your output path to gulp-tsc by outDir option.
Output files are going under {working directory}/foo/bar/, but sourcemap files and declaration files will contain a relative path to source files from {working directory}/foo/ which is not correct.
To fix the relative path, just specify outDir same as your gulp.dest path.
Since gulp-tsc uses tsc command internally for compiling TypeScript files, compiled JavaScript files require to be written on the file system temporarily.
For those compiled files, gulp-tsc creates a temporary directory named gulp-tsc-tmp-* in the current working directory. You can change the location of the temporary directory by options.tmpDir.
In addition, gulp-tsc also creates a temporary file named .gulp-tsc-tmp-*.ts in your source root directory while compiling. The source root is determined by your gulp.src(). (e.g. For gulp.src("src/**/*.ts"), the source root is src/)
This is required for keeping your source directory structure in output since tsc command omits the common part of your output paths.
If you do not need to keep the structure, you can skip creating the temporary file by setting options.keepTree to false.
请发表评论