fix(core): stringify shouldn't throw when toString returns null/undefined (#14975)

Fixes #14948

PR Close #14975
This commit is contained in:
Dzmitry Shylovich
2017-03-07 10:31:28 +03:00
committed by Miško Hevery
parent 0759911431
commit 8e6995c91e
2 changed files with 24 additions and 0 deletions

View File

@ -69,6 +69,11 @@ export function stringify(token: any): string {
}
const res = token.toString();
if (res == null) {
return '' + res;
}
const newLineIndex = res.indexOf('\n');
return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
}