Skip to content

Commit

Permalink
fix(@ngtools/webpack): diagnose typescript warnings as warnings
Browse files Browse the repository at this point in the history
Previously, we were reporting all diagnostics as errors. Now only Typescript errors
will be reported as real errors to webpack. Messages and warnings will be warnings.

Fixes #5623
  • Loading branch information
hansl committed Mar 28, 2017
1 parent 55a4e62 commit c55b5dc
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions packages/@ngtools/webpack/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ export class AotPlugin implements Tapable {

const original = consumer.originalPositionFor({ line, column: character });
return {
line: original.line,
character: original.column,
line: typeof original.line == 'number' ? original.line : line,
character: typeof original.column == 'number' ? original.column : character,
fileName: original.source || fileName
};
} catch (e) {
Expand Down Expand Up @@ -390,19 +390,25 @@ export class AotPlugin implements Tapable {
);

if (diagnostics.length > 0) {
const message = diagnostics
.map(diagnostic => {
const position = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);

const sourceText = diagnostic.file.getFullText();
let {line, character, fileName} = this._translateSourceMap(sourceText,
diagnostic.file.fileName, position);

const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
return `${fileName} (${line + 1},${character + 1}): ${message}`;
})
.join('\n');
this._compilation.errors.push(message);
diagnostics.forEach(diagnostic => {
const position = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);

const sourceText = diagnostic.file.getFullText();
let {line, character, fileName} = this._translateSourceMap(sourceText,
diagnostic.file.fileName, position);

const messageText = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
const message = `${fileName} (${line + 1},${character + 1}): ${messageText}`;

switch (diagnostic.category) {
case ts.DiagnosticCategory.Error:
this._compilation.errors.push(message);
break;

default:
this._compilation.warnings.push(message);
}
});
}
}

Expand Down

0 comments on commit c55b5dc

Please sign in to comment.