ember-lifeline icon indicating copy to clipboard operation
ember-lifeline copied to clipboard

Type miss-match between `runTask` and `cancelTask`

Open vstefanovic97 opened this issue 11 months ago • 2 comments

Right now if we do

const timerId = runTask(this, () => {}, 100);

cancelTask(this, timerId);

We will get the following error

Argument of type 'Timer' is not assignable to parameter of type 'EmberRunTimer'.
  Type 'number' is not assignable to type 'EmberRunTimer'.ts(2345)

Not sure exactly if runTask signature is wrong or are the arguments for cancelTask wrong but I'm definitely sure the types should match

ps. this probably relates to https://github.com/ember-lifeline/ember-lifeline/issues/876

vstefanovic97 avatar Mar 14 '24 08:03 vstefanovic97

Also I'd recommend rewritting tests to TS to prevent such type regressions in the future

vstefanovic97 avatar Mar 14 '24 09:03 vstefanovic97

we have a couple of places in our code base.

where I see people doing cancelTask(this, this._runTaskId as unknown as EmberRunTimer); because of the mismatch

angelayanpan avatar Oct 08 '24 16:10 angelayanpan