- better errors when noEmitOnError set to true

This commit is contained in:
ezolenko 2017-02-15 22:07:26 -07:00
parent 32287495d4
commit 045b172275
4 changed files with 37 additions and 12 deletions

View File

@ -406,8 +406,16 @@ function typescript(options) {
var snapshot = servicesHost.setSnapshot(id, code);
var result = cache.getCompiled(id, snapshot, function () {
var output = services.getEmitOutput(id);
if (output.emitSkipped)
_this.error({ message: colors.red("failed to transpile " + id) });
if (output.emitSkipped) {
var diagnostics = cache.getDiagnostics(id, snapshot, function () {
return services
.getCompilerOptionsDiagnostics()
.concat(services.getSyntacticDiagnostics(id))
.concat(services.getSemanticDiagnostics(id));
});
printDiagnostics(_this, diagnostics);
_this.error(colors.red("failed to transpile " + id));
}
var transpiled = _.find(output.outputFiles, function (entry) { return _.endsWith(entry.name, ".js"); });
var map$$1 = _.find(output.outputFiles, function (entry) { return _.endsWith(entry.name, ".map"); });
return {
@ -418,6 +426,7 @@ function typescript(options) {
return result;
},
outro: function () {
context.debug("outro");
cache.compileDone();
if (options.check) {
cache.walkTree(function (id) {

View File

@ -411,8 +411,16 @@ function typescript(options) {
var snapshot = servicesHost.setSnapshot(id, code);
var result = cache.getCompiled(id, snapshot, function () {
var output = services.getEmitOutput(id);
if (output.emitSkipped)
_this.error({ message: red("failed to transpile " + id) });
if (output.emitSkipped) {
var diagnostics = cache.getDiagnostics(id, snapshot, function () {
return services
.getCompilerOptionsDiagnostics()
.concat(services.getSyntacticDiagnostics(id))
.concat(services.getSemanticDiagnostics(id));
});
printDiagnostics(_this, diagnostics);
_this.error(red("failed to transpile " + id));
}
var transpiled = find(output.outputFiles, function (entry) { return endsWith(entry.name, ".js"); });
var map$$1 = find(output.outputFiles, function (entry) { return endsWith(entry.name, ".map"); });
return {
@ -423,6 +431,7 @@ function typescript(options) {
return result;
},
outro: function () {
context.debug("outro");
cache.compileDone();
if (options.check) {
cache.walkTree(function (id) {

View File

@ -1,12 +1,8 @@
interface Message
{
message: string;
}
export interface IRollupContext
{
warn(message: Message | string): void;
error(message: Message | string): void;
warn(message: string): void;
error(message: string): void;
}
export interface IContext

View File

@ -72,7 +72,7 @@ function parseTsConfig()
return configParseResult;
}
function printDiagnostics(context: IContext, diagnostics: IDiagnostics[])
function printDiagnostics(context: IContext | IRollupContext, diagnostics: IDiagnostics[])
{
_.each(diagnostics, (diagnostic) =>
{
@ -169,7 +169,17 @@ export default function typescript (options: IOptions)
const output = services.getEmitOutput(id);
if (output.emitSkipped)
this.error({ message: colors.red(`failed to transpile ${id}`)});
{
const diagnostics = cache.getDiagnostics(id, snapshot, () =>
{
return services
.getCompilerOptionsDiagnostics()
.concat(services.getSyntacticDiagnostics(id))
.concat(services.getSemanticDiagnostics(id));
});
printDiagnostics(this, diagnostics);
this.error(colors.red(`failed to transpile ${id}`));
}
const transpiled = _.find(output.outputFiles, (entry: ts.OutputFile) => _.endsWith(entry.name, ".js") );
const map = _.find(output.outputFiles, (entry: ts.OutputFile) => _.endsWith(entry.name, ".map") );
@ -185,6 +195,7 @@ export default function typescript (options: IOptions)
outro(): void
{
context.debug("outro");
cache.compileDone();
if (options.check)