我正在用VisualStudio开发一个Angular2/Typescript应用程序,并想设置我自己的ts编译器,但每当我运行它,它发现错误时,我没有得到关于它们的详细信息,只是这样:
[16:22:23] Starting 'compile:typescript'...
[16:22:26] TypeScript: 1 semantic error
[16:22:26] TypeScript: emit failed
[16:22:26] Finished 'compile:typescript' after 3.14 s我的gulpfile.js有点大,但相关的部分在这里:
var gulp = require('gulp');
var del = require('del');
var ts = require("gulp-typescript");
var gutil = require("gulp-util");
var watchifiy = require('watchify');
var sourcemaps = require('gulp-sourcemaps');
// -------------------------- COMPILE TS ---------------------------
gulp.task('compile:typescript', function () {
var tsResult = gulp.src('./Scripts/**/*.ts', { base: './Scripts' })
.pipe(sourcemaps.init())
.pipe(ts(
ts.createProject('Scripts/tsconfig.json'),
undefined,
ts.reporter.fullReporter()));
return tsResult.js
.pipe(sourcemaps.write())
.pipe(gulp.dest('./Scripts'));
})tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"noEmitOnError": true
},
"exclude": [
"node_modules",
"typings/globals",
"typings/index.d.ts"
]
}会对任何想法心存感激。
发布于 2016-06-27 22:53:41
更新
这看起来像是一个已知的bug,发现了here。
原始
我建议使用gulp-debug包,它允许您在任务中使用.pipe并捕获标准输出。
调试黑胶文件流以查看通过gulp管道运行的文件
gulpfile.js
var debug = require("gulp-debug");
gulp.task('compile:typescript', function () {
var tsResult = gulp.src('./Scripts/**/*.ts', { base: './Scripts' })
.pipe(sourcemaps.init())
.pipe(debug()) // here...
.pipe(ts(
ts.createProject('Scripts/tsconfig.json'),
undefined,
ts.reporter.fullReporter()));
return tsResult.js
.pipe(sourcemaps.write())
.pipe(gulp.dest('./Scripts'));
})您需要将其添加到package.json中的devDependencies列表中,以便npm能够安装它。
发布于 2017-02-21 01:49:52
我也遇到过类似的问题。从我的tsconfig.json文件中删除"noEmit": true,解决了这个问题。
尝试从您的"noEmitOnError": true中删除或将其设置为false。
https://stackoverflow.com/questions/38056843
复制相似问题