问题描述
这是前几天工作正常,所以我不确定自那以后发生了什么变化(除了更新到ASP.NET Core RC2并为VS2015安装了一些扩展程序之外,我记得)
问题是,当从VS2015运行一个Gulp任务来编译我的打字稿文件时,如果出现错误,例如:
<$编译脚本到javascript
[10:02:56] TypeScript:1语义错误
[10:02:56] TypeScript:发出成功(有错误)
[10:02:56]在2.47 s
之后完成'compile'处理终止于代码0.
没有任何描述。
在CMD中:
$ tsc -v
版本1.8.10
PM>在VS2015包管理器控制台中: tsc -v
版本1.8.10
所以我认为VS2015至少使用相同的打字机编译器在PATH中,这应该不成问题。
我的大嘴巴任务:
gulp.task('compile',function(){
log('将编译脚本编译为javascript');
return gulp
.src config.allts)
.pipe($。sourcemaps.init())
.pipe($。typescript({
noImplicitAny:true,$ b $ target:'ES5'
$ b .pipe($。sourcemaps.write('。'))
.pipe(gulp.dest(config.compileFolder));
});
我正在使用:
gulp-typescript:2.10.0
虽然我已经尝试过最新的:
gulp-typescript:2.13.4
没有运气。
据我所知,我不需要tsconfig。 json在我的项目的根源,因为我正在使用 gulp-typescript
,并且我已经将compilerOptions传递给了gulp任务本身,所以我删除了我所拥有的tsconfig.json因为它似乎没有被使用。
如果我从我的gulp任务中删除所有compilerOptions:
<$ p ('编译',函数(){
日志('将编译脚本编译为javascript');
返回gulp
.src(config。 )
.pipe($。
.pipe($。sourcemaps.init())
.pipe($。typescript({
// removed
}))
.pipe $ .sourcemaps.write( 。'))
.pipe(gulp.dest(config.compileFolder));
});
更多的语义错误也没有描述。
[10:12:57]将脚本编译为javascript
[10:13:00] TypeScript:184语义错误
[10:13:00] TypeScript:发出成功(有错误)
[10:13:01]在3.83 s
之后完成'compile'过程以代码0结束。
所以这些选项肯定会被使用。
如果在我的CMD中,有一个打字稿,并尝试编译它:
C:/> Sample / app> tsc mytestfile.ts
我可以正确地看到所有的打字稿编译错误。 b
请参阅Task Runner Explorer中的打字稿错误消息。
This is something that some days ago was working fine, so I am not sure what has changed since then (other than updating to ASP.NET Core RC2 and installing some extension for VS2015 as I recall)
The issue is that when running from VS2015 a Gulp task to compile my typescript files, if there is an error it shows for example:
[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.
without any description of the error.
in CMD:
$ tsc -v
Version 1.8.10
In VS2015 Package Manager console:
PM> tsc -v
Version 1.8.10
so I think VS2015 is at least using the same typescript compiler in PATH and that shouldn't be a problem. Also this is the latest version but I have tried with 1.7 and the same thing happens.
My gulp task:
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));
});
And I am using:
"gulp-typescript": "2.10.0"
although I have tried with the latest:
"gulp-typescript": "2.13.4"
with no luck.
As I understood I don't need a tsconfig.json at the root of my project since I am using gulp-typescript
and I am passing already the compilerOptions in the gulp task itself, so I have deleted the tsconfig.json I had because it does not seem to be used.
If I remove all the compilerOptions from my gulp task:
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));
});
I get more semantic errors also without description.
[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.
so the options are definitely being used.
And if in my CMD I go to the folder where I have a typescript and try to compile it with:
C:/>Sample/app> tsc mytestfile.ts
I can properly see all the typescript compilation errors.
After doing so I could once again see typescript error messages in Task Runner Explorer.
这篇关于使用gulp-typescript不能在VS2015中显示Typescript编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!