@@ -43,8 +43,8 @@ export function wrapWithCurrentZone<T extends Function>(callback: T, source: str
4343}
4444
4545export function scheduleMacroTaskWithCurrentZone (
46- source : string , callback : Function , data : TaskData , customSchedule : ( task : Task ) => void ,
47- customCancel : ( task : Task ) => void ) : MacroTask {
46+ source : string , callback : Function , data ? : TaskData , customSchedule ? : ( task : Task ) => void ,
47+ customCancel ? : ( task : Task ) => void ) : MacroTask {
4848return Zone . current . scheduleMacroTask ( source , callback , data , customSchedule , customCancel ) ;
4949}
5050
@@ -229,7 +229,7 @@ export function patchProperty(obj: any, prop: string, prototype?: any) {
229229// so we should use original native get to retrieve the handler
230230let value = originalDescGet && originalDescGet . call ( this ) ;
231231if ( value ) {
232- desc . set . call ( this , value ) ;
232+ desc ! . set ! . call ( this , value ) ;
233233if ( typeof target [ REMOVE_ATTRIBUTE ] === 'function' ) {
234234target . removeAttribute ( prop ) ;
235235}
@@ -242,7 +242,7 @@ export function patchProperty(obj: any, prop: string, prototype?: any) {
242242ObjectDefineProperty ( obj , prop , desc ) ;
243243}
244244
245- export function patchOnProperties ( obj : any , properties : string [ ] , prototype ?: any ) {
245+ export function patchOnProperties ( obj : any , properties : string [ ] | null , prototype ?: any ) {
246246if ( properties ) {
247247for ( let i = 0 ; i < properties . length ; i ++ ) {
248248patchProperty ( obj , 'on' + properties [ i ] , prototype ) ;
@@ -337,7 +337,7 @@ export function patchClass(className: string) {
337337export function patchMethod (
338338target : any , name : string ,
339339patchFn : ( delegate : Function , delegateName : string , name : string ) => ( self : any , args : any [ ] ) =>
340- any ) : Function {
340+ any ) : Function | null {
341341let proto = target ;
342342while ( proto && ! proto . hasOwnProperty ( name ) ) {
343343proto = ObjectGetPrototypeOf ( proto ) ;
@@ -348,14 +348,14 @@ export function patchMethod(
348348}
349349
350350const delegateName = zoneSymbol ( name ) ;
351- let delegate : Function ;
351+ let delegate : Function | null = null ;
352352if ( proto && ! ( delegate = proto [ delegateName ] ) ) {
353353delegate = proto [ delegateName ] = proto [ name ] ;
354354// check whether proto[name] is writable
355355// some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob
356356const desc = proto && ObjectGetOwnPropertyDescriptor ( proto , name ) ;
357357if ( isPropertyWritable ( desc ) ) {
358- const patchDelegate = patchFn ( delegate , delegateName , name ) ;
358+ const patchDelegate = patchFn ( delegate ! , delegateName , name ) ;
359359proto [ name ] = function ( ) {
360360return patchDelegate ( this , arguments as any ) ;
361361} ;
@@ -375,22 +375,21 @@ export interface MacroTaskMeta extends TaskData {
375375// TODO: @JiaLiPassion , support cancel task later if necessary
376376export function patchMacroTask (
377377obj : any , funcName : string , metaCreator : ( self : any , args : any [ ] ) => MacroTaskMeta ) {
378- let setNative : Function = null ;
378+ let setNative : Function | null = null ;
379379
380380function scheduleTask ( task : Task ) {
381381const data = < MacroTaskMeta > task . data ;
382382data . args [ data . cbIdx ] = function ( ) {
383383task . invoke . apply ( this , arguments ) ;
384384} ;
385- setNative . apply ( data . target , data . args ) ;
385+ setNative ! . apply ( data . target , data . args ) ;
386386return task ;
387387}
388388
389389setNative = patchMethod ( obj , funcName , ( delegate : Function ) => function ( self : any , args : any [ ] ) {
390390const meta = metaCreator ( self , args ) ;
391391if ( meta . cbIdx >= 0 && typeof args [ meta . cbIdx ] === 'function' ) {
392- return scheduleMacroTaskWithCurrentZone (
393- meta . name , args [ meta . cbIdx ] , meta , scheduleTask , null ) ;
392+ return scheduleMacroTaskWithCurrentZone ( meta . name , args [ meta . cbIdx ] , meta , scheduleTask ) ;
394393} else {
395394// cause an error by calling it directly.
396395return delegate . apply ( self , args ) ;
@@ -407,14 +406,14 @@ export interface MicroTaskMeta extends TaskData {
407406
408407export function patchMicroTask (
409408obj : any , funcName : string , metaCreator : ( self : any , args : any [ ] ) => MicroTaskMeta ) {
410- let setNative : Function = null ;
409+ let setNative : Function | null = null ;
411410
412411function scheduleTask ( task : Task ) {
413412const data = < MacroTaskMeta > task . data ;
414413data . args [ data . cbIdx ] = function ( ) {
415414task . invoke . apply ( this , arguments ) ;
416415} ;
417- setNative . apply ( data . target , data . args ) ;
416+ setNative ! . apply ( data . target , data . args ) ;
418417return task ;
419418}
420419
0 commit comments