Skip to content

Commit d4b8c1c

Browse files
committed
Handle noEmit(onError) correctly with out(File), fix #416
1 parent 5cf1ec9 commit d4b8c1c

File tree

5 files changed

+39
-5
lines changed

5 files changed

+39
-5
lines changed

lib/compiler.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,13 @@ export class ProjectCompiler implements ICompiler {
113113

114114
result.emitErrors += emitOutput.diagnostics.length;
115115
this.reportDiagnostics(emitOutput.diagnostics);
116-
116+
117+
if (emitOutput.emitSkipped) {
118+
result.emitSkipped = true;
119+
}
120+
121+
if (!jsFileName) return;
122+
117123
let base: string;
118124
let baseDeclarations: string;
119125
if (file) {
@@ -138,10 +144,6 @@ export class ProjectCompiler implements ICompiler {
138144
if (dtsContent !== undefined) {
139145
this.project.output.writeDts(baseDeclarations, dtsFileName, dtsContent, file ? file.gulp.cwd : currentDirectory);
140146
}
141-
142-
if (emitOutput.emitSkipped) {
143-
result.emitSkipped = true;
144-
}
145147
}
146148

147149
private reportDiagnostics(diagnostics: ts.Diagnostic[]) {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
TypeScript error: test/noEmit/a.ts(1,14): error TS6131: Cannot compile modules using option 'outFile' unless the '--module' flag is 'amd' or 'system'.
2+
{
3+
"transpileErrors": 0,
4+
"optionsErrors": 0,
5+
"syntaxErrors": 0,
6+
"globalErrors": 0,
7+
"semanticErrors": 1,
8+
"declarationErrors": 0,
9+
"emitErrors": 0,
10+
"emitSkipped": true
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
TypeScript error: test/noEmit/a.ts(1,14): error TS6131: Cannot compile modules using option 'outFile' unless the '--module' flag is 'amd' or 'system'.
2+
{
3+
"transpileErrors": 0,
4+
"optionsErrors": 0,
5+
"syntaxErrors": 0,
6+
"globalErrors": 0,
7+
"semanticErrors": 1,
8+
"declarationErrors": 0,
9+
"emitErrors": 0,
10+
"emitSkipped": true
11+
}

test/noEmit/a.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export class Hello {
2+
value: string;
3+
}

test/noEmit/gulptask.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
var gulp = require('gulp');
2+
3+
module.exports = function(newTS, lib, output, reporter) {
4+
return gulp.src('test/noEmit/**/*.ts')
5+
.pipe(newTS({ noEmit: true, typescript: lib, outFile: 'foo.js' }, reporter))
6+
.pipe(gulp.dest(output));
7+
}

0 commit comments

Comments
 (0)