license import { zoneSymbol } from './utils' ; Zone . __load_patch ( 'toString' , ( global ) => { const originalFunctionToString = Function . prototype . toString ; const ORIGINAL_DELEGATE_SYMBOL = zoneSymbol ( 'OriginalDelegate' ) ; const PROMISE_SYMBOL = zoneSymbol ( 'Promise' ) ; const ERROR_SYMBOL = zoneSymbol ( 'Error' ) ; const newFunctionToString = function toString ( ) { if ( typeof this === 'function' ) { const originalDelegate = this [ ORIGINAL_DELEGATE_SYMBOL ] ; if ( originalDelegate ) { if ( typeof originalDelegate === 'function' ) { return originalFunctionToString . call ( originalDelegate ) ; } else { return Object . prototype . toString . call ( originalDelegate ) ; } } if ( this === Promise ) { const nativePromise = global [ PROMISE_SYMBOL ] ; if ( nativePromise ) { return originalFunctionToString . call ( nativePromise ) ; } } if ( this === Error ) { const nativeError = global [ ERROR_SYMBOL ] ; if ( nativeError ) { return originalFunctionToString . call ( nativeError ) ; } } } return originalFunctionToString . call ( this ) ; } ; ( newFunctionToString as any ) [ ORIGINAL_DELEGATE_SYMBOL ] = originalFunctionToString ; Function . prototype . toString = newFunctionToString ; const originalObjectToString = Object . prototype . toString ; const PROMISE_OBJECT_TO_STRING = '[object Promise]' ; Object . prototype . toString = function ( ) { if ( this instanceof Promise ) { return PROMISE_OBJECT_TO_STRING ; } return originalObjectToString . call ( this ) ; } ; } ) ;