This reverts commit 8555a3a3cd
.
Reverted because of https://github.com/angular/angular/issues/23440
PR Close #23442
This commit is contained in:
parent
acf6781ccc
commit
1d1e75ee2b
|
@ -163,8 +163,6 @@ export interface OutputContext {
|
||||||
importExpr(reference: any, typeParams?: o.Type[]|null, useSummaries?: boolean): o.Expression;
|
importExpr(reference: any, typeParams?: o.Type[]|null, useSummaries?: boolean): o.Expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAX_LENGTH_STRINGIFY = 100;
|
|
||||||
|
|
||||||
export function stringify(token: any): string {
|
export function stringify(token: any): string {
|
||||||
if (typeof token === 'string') {
|
if (typeof token === 'string') {
|
||||||
return token;
|
return token;
|
||||||
|
@ -186,27 +184,16 @@ export function stringify(token: any): string {
|
||||||
return `${token.name}`;
|
return `${token.name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let res;
|
// WARNING: do not try to `JSON.stringify(token)` here
|
||||||
try {
|
// see https://github.com/angular/angular/issues/23440
|
||||||
res = JSON.stringify(token);
|
const res = token.toString();
|
||||||
} catch {
|
|
||||||
res = token.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
return '' + res;
|
return '' + res;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newLineIndex = res.indexOf('\n');
|
const newLineIndex = res.indexOf('\n');
|
||||||
if (0 < newLineIndex) {
|
return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
|
||||||
res = res.substring(0, newLineIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MAX_LENGTH_STRINGIFY < res.length) {
|
|
||||||
res = res.substring(0, MAX_LENGTH_STRINGIFY) + '...';
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -409,7 +409,7 @@ import {TEST_COMPILER_PROVIDERS} from './test_bindings';
|
||||||
|
|
||||||
expect(() => { resolver.getNgModuleMetadata(InvalidModule); })
|
expect(() => { resolver.getNgModuleMetadata(InvalidModule); })
|
||||||
.toThrowError(
|
.toThrowError(
|
||||||
`Unexpected value '{"ngModule":true}' imported by the module 'InvalidModule'. Please add a @NgModule annotation.`);
|
`Unexpected value '[object Object]' imported by the module 'InvalidModule'. Please add a @NgModule annotation.`);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {fakeAsync} from '@angular/core/testing/src/fake_async';
|
import {fakeAsync} from '@angular/core/testing/src/fake_async';
|
||||||
|
import {SyncAsync, escapeRegExp, splitAtColon, utf8Encode} from '../src/util';
|
||||||
import {SyncAsync, escapeRegExp, splitAtColon, stringify, utf8Encode} from '../src/util';
|
|
||||||
|
|
||||||
{
|
{
|
||||||
describe('util', () => {
|
describe('util', () => {
|
||||||
|
@ -76,23 +75,5 @@ import {SyncAsync, escapeRegExp, splitAtColon, stringify, utf8Encode} from '../s
|
||||||
([input, output]: [string, string]) => { expect(utf8Encode(input)).toEqual(output); });
|
([input, output]: [string, string]) => { expect(utf8Encode(input)).toEqual(output); });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('stringify', () => {
|
|
||||||
it('should pretty print an Object', () => {
|
|
||||||
const result = stringify({hello: 'world'});
|
|
||||||
expect(result).toBe('{"hello":"world"}');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should truncate large object', () => {
|
|
||||||
const result = stringify({
|
|
||||||
selector: 'app-root',
|
|
||||||
preserveWhitespaces: false,
|
|
||||||
templateUrl: './app.component.ng.html',
|
|
||||||
styleUrls: ['./app.component.css']
|
|
||||||
});
|
|
||||||
expect(result).toBe(
|
|
||||||
'{"selector":"app-root","preserveWhitespaces":false,"templateUrl":"./app.component.ng.html","styleUrl...');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
|
@ -1004,9 +1004,6 @@
|
||||||
{
|
{
|
||||||
"name": "LiteralPrimitive"
|
"name": "LiteralPrimitive"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "MAX_LENGTH_STRINGIFY"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "MEANING_SEPARATOR"
|
"name": "MEANING_SEPARATOR"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue