1+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
2+
13import WorkerPoolFunction from './WorkerPoolFunction.js'
24import WorkerPoolProgressCallback from './WorkerPoolProgressCallback.js'
35import WorkerPoolRunTasksResult from './WorkerPoolRunTasksResult.js'
@@ -104,9 +106,8 @@ class WorkerPool {
104106 const info = this . runInfo [ infoIndex ]
105107
106108 if ( info ?. canceled === true ) {
109+ info . reject ! ( 'Remaining tasks canceled' )
107110 this . clearTask ( info . index )
108- // @ts -expect-error: error TS2722: Cannot invoke an object which is
109- info ?. reject ( 'Remaining tasks canceled' )
110111 return
111112 }
112113
@@ -129,17 +130,13 @@ class WorkerPool {
129130 this . addTask ( infoIndex , reTask [ 0 ] , reTask [ 1 ] )
130131 } else if ( ! info . addingTasks && info . runningWorkers === 0 ) {
131132 const results = info . results
133+ info . resolve ! ( results )
132134 this . clearTask ( info . index )
133- // @ts -expect-error: error TS2722: Cannot invoke an object which is
134- // possibly 'undefined'.
135- info ?. resolve ( results )
136135 }
137136 }
138137 } ) . catch ( ( error ) => {
138+ info . reject ! ( error )
139139 this . clearTask ( info . index )
140- // @ts -expect-error: error TS2722: Cannot invoke an object which is
141- // possibly 'undefined'.
142- info ?. reject ( error )
143140 } )
144141 } else {
145142 if ( info . runningWorkers !== 0 || info . postponed ) {
@@ -162,6 +159,8 @@ class WorkerPool {
162159 this . runInfo [ clearIndex ] . taskQueue = [ ]
163160 this . runInfo [ clearIndex ] . progressCallback = null
164161 this . runInfo [ clearIndex ] . canceled = null
162+ this . runInfo [ clearIndex ] . reject = ( ) => { }
163+ this . runInfo [ clearIndex ] . resolve = ( ) => { }
165164 }
166165}
167166
0 commit comments