这是几天前工作正常的事情,所以我不确定自那以后发生了什么变化(除了更新到ASP.NET核心RC2和安装一些VS2015扩展(我记得))。
问题是,当从VS2015运行一个Gulp任务来编译我的类型记录文件时,如果有一个错误,它会显示如下:
[10:02:54] Compiling typescript into javascript
[10:02:56] TypeScript: 1 semantic error
[10:02:56] TypeScript: emit succeeded (with errors)
[10:02:56] Finished 'compile' after 2.47 s
Process terminated with code 0.没有对错误的任何描述。
在CMD中:
$ tsc -v
Version 1.8.10在VS2015包管理器控制台中:
PM> tsc -v
Version 1.8.10因此,我认为VS2015至少在PATH中使用相同的类型记录编译器,这不应该是个问题。这也是最新的版本,但我已经尝试了1.7和同样的事情发生。
我的任务是:
gulp.task('compile', function () {
log('Compiling typescript into javascript');
return gulp
.src(config.allts)
.pipe($.sourcemaps.init())
.pipe($.typescript({
noImplicitAny: true,
target: 'ES5'
}))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest(config.compileFolder));
});我用的是:
"gulp-typescript": "2.10.0"虽然我试过最新的:
"gulp-typescript": "2.13.4"没有运气。
据我所知,我不需要一个tsconfig.json作为我的项目的根,因为我使用的是gulp-typescript,而且我已经在gulp任务本身中传递了compilerOptions,所以我删除了所拥有的tsconfig.json,因为它似乎没有被使用。
如果我从我的gulp任务中删除了所有的compilerOptions:
gulp.task('compile', function () {
log('Compiling typescript into javascript');
return gulp
.src(config.allts)
.pipe($.sourcemaps.init())
.pipe($.typescript({
//removed
}))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest(config.compileFolder));
});我得到更多的语义错误,也没有描述。
[10:12:57] Compiling typescript into javascript
[10:13:00] TypeScript: 184 semantic errors
[10:13:00] TypeScript: emit succeeded (with errors)
[10:13:01] Finished 'compile' after 3.83 s
Process terminated with code 0.所以这些选项肯定被使用了。
如果在我的CMD中,我转到有一个类型记录的文件夹,并尝试用以下方法编译它:
C:/>Sample/app> tsc mytestfile.ts我能正确地看到所有的打字本编译错误。
你知道我的VS2015或者我的打字记录可能有什么问题吗?
UPDATE:我已经尝试过用gulp来代替gulp,而且效果很好。,所以问题一定是关于gulp打字稿。
gulp.task('compile', function () {
log('Compiling typescript into javascript');
return gulp
.src(config.allts)
.pipe($.sourcemaps.init())
.pipe($.tsc({
noImplicitAny: true,
target: 'ES5'
}))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest(config.compileFolder));
});发布于 2016-06-22 14:34:17
至少我找到了部分答案。如果您从nodejs命令提示符中运行一站式类型记录,它将显示错误。但是,在visual studio任务运行程序中,错误信息的打印方式没有显示。
如果我将用于类型记录的报告改为此,它将显示错误(将此函数添加到gulpfile.js中)。
function visualStudioReporter() {
return {
error: function (error) {
//This works
gutil.log("Typescript: error", error.message);
//This isn't shown
console.error(error.message);
},
finish: ts.reporter.defaultReporter().finish
};
}现在你可以用这样的记者
var ts = require("gulp-typescript")
gulp.task("compile", function() {
gulp.src("./**/*.ts")
.pipe(ts(tsProject, undefined, visualStudioReporter()))
});https://stackoverflow.com/questions/37424800
复制相似问题