Revert "fix(compiler): Pretty print object instead of [Object object] (#22689)" (#23442)

This reverts commit 8555a3a3cd.

Reverted because of https://github.com/angular/angular/issues/23440

PR Close #23442
This commit is contained in:
Victor Berchet
2018-04-18 17:09:41 -07:00
parent acf6781ccc
commit 1d1e75ee2b
4 changed files with 7 additions and 42 deletions

View File

@ -163,8 +163,6 @@ export interface OutputContext {
importExpr(reference: any, typeParams?: o.Type[]|null, useSummaries?: boolean): o.Expression;
}
const MAX_LENGTH_STRINGIFY = 100;
export function stringify(token: any): string {
if (typeof token === 'string') {
return token;
@ -186,27 +184,16 @@ export function stringify(token: any): string {
return `${token.name}`;
}
let res;
try {
res = JSON.stringify(token);
} catch {
res = token.toString();
}
// WARNING: do not try to `JSON.stringify(token)` here
// see https://github.com/angular/angular/issues/23440
const res = token.toString();
if (res == null) {
return '' + res;
}
const newLineIndex = res.indexOf('\n');
if (0 < newLineIndex) {
res = res.substring(0, newLineIndex);
}
if (MAX_LENGTH_STRINGIFY < res.length) {
res = res.substring(0, MAX_LENGTH_STRINGIFY) + '...';
}
return res;
return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
}
/**