Closed zxti closed 5 years ago
Good catch, the issue reproduces with the following test case (added inside type-collector-snippet.spec.ts
):
it('should gracefully deal with toString() method throwing an error', () => {
function f() { /* noop */ }
f.toString = () => { throw new Error('Dont call this method'); };
expect($_$twiz.typeName(f)).toBe(
'() => any',
);
});
Would you be interested in working on a PR that fixes this?
Thanks for going ahead and fixing this!
The
value.toString()
call below can cause Typewiz to crash, since user code can override.toString()
with arbitrary broken code. I ran into this trying to use the Ant library, for instance—rc-editor-mention overrides the class method Mention.toString.