使用 gulp-typescript 在 VS2015 中未显示 Typescript 编译错误 [英] Typescript compilation errors not being displayed in VS2015 using gulp-typescript

查看:25
本文介绍了使用 gulp-typescript 在 VS2015 中未显示 Typescript 编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是几天前工作正常的东西,所以我不确定从那以后发生了什么变化(除了更新到 ASP.NET Core RC2 并为 VS2015 安装了一些扩展,我记得)

问题是当从 VS2015 运行 Gulp 任务来编译我的打字稿文件时,如果出现错误,它会显示例如:

[10:02:54] 将 typescript 编译成 javascript[10:02:56] TypeScript:1 个语义错误[10:02:56] TypeScript:发射成功(有错误)[10:02:56] 2.47 秒后完成编译"进程以代码 0 终止.

没有任何错误描述.

在 CMD 中:

$ tsc -v版本 1.8.10

在 VS2015 包管理器控制台中:

PM>tsc -v版本 1.8.10

所以我认为 VS2015 至少在 PATH 中使用了相同的打字稿编译器,这应该不是问题.这也是最新版本,但我尝试了 1.7 并且发生了同样的事情.

我的吞咽任务:

gulp.task('compile', function () {log('将 typescript 编译成 javascript');返回一口.src(config.allts).pipe($.sourcemaps.init()).pipe($.typescript({noImplicitAny:真,目标:'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('将 typescript 编译成 javascript');返回一口.src(config.allts).pipe($.sourcemaps.init()).pipe($.typescript({//移除})).pipe($.sourcemaps.write('.')).pipe(gulp.dest(config.compileFolder));});

我也得到了更多没有描述的语义错误.

[10:12:57] 将 typescript 编译成 javascript[10:13:00] TypeScript:184 个语义错误[10:13:00] TypeScript:发射成功(有错误)[10:13:01] 3.83 秒后完成编译"进程以代码 0 终止.

所以肯定会使用这些选项.

如果在我的 CMD 中,我会转到我有打字稿的文件夹并尝试使用以下命令进行编译:

C:/>Sample/app>tsc mytestfile.ts

我可以正确看到所有的打字稿编译错误.

知道我的 VS2015 或 gulp-typescript 有什么问题吗?

更新:我尝试使用 gulp-tsc 代替 gulp-typescript,效果很好.所以问题一定出在 gulp-typescript

gulp.task('compile', function () {log('将 typescript 编译成 javascript');返回一口.src(config.allts).pipe($.sourcemaps.init()).pipe($.tsc({noImplicitAny:真,目标:'ES5'})).pipe($.sourcemaps.write('.')).pipe(gulp.dest(config.compileFolder));});

解决方案

如果您安装了 Microsoft .Net Core 1.0.0 RC2 Tooling Preview 1.看起来有问题:

在此之前卸载工具预览 1 并重新安装 vs 2015 的 Web 开发工具将解决未显示错误详细信息的问题.

我也有同样的问题.因为我没有使用 .Net Core 1 RC2 Preview 的功能.我能够通过 Github 上的错误报告中提到的解决方法解决打字稿错误未显示的问题:

  1. 卸载Microsoft .Net Core 1.0.0 RC2 - VS 2015 Tooling Preview 1"
  2. 在添加/删除 Visual Studio 、修改中重新安装 Visual Studio 2015 的 Web 开发工具.

这样做之后,我可以再次在 Task Runner Explorer 中看到 typescript 错误消息.

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.

Any idea what might be wrong in my VS2015 or my gulp-typescript?

UPDATE: I have tried with gulp-tsc instead gulp-typescript and it works well. So the problem must be with gulp-typescript

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));
});

解决方案

If you have Microsoft .Net Core 1.0.0 RC2 Tooling Preview 1 installed. Looks like there is an issue: After installing Preview 1 of the tooling, TypeScript errors aren't shown #526

Updated After release of .Net Core 1 / Tooling Preview 2

Updating to / Installing the release version of .Net Core 1.0 which updates the Tooling to Preview 2 resolves this issue.

Prior to this uninstalling the tooling preview 1 and re-installing web development tools for vs 2015 would resolve the issue where error details are not shown.

I had the same issue. Since I was not using the functionality of .Net Core 1 RC2 Preview. I was able to resolve the issue with typescript errors not being shown with the workaround mentioned in the bug report on Github by:

  1. uninstalling 'Microsoft .Net Core 1.0.0 RC2 - VS 2015 Tooling Preview 1'
  2. Reinstalling Web Development tools for visual studio 2015 in add/remove visual studio , Modify.

After doing so I could once again see typescript error messages in Task Runner Explorer.

这篇关于使用 gulp-typescript 在 VS2015 中未显示 Typescript 编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆