1.7 KiB
kind, description
| kind | description |
|---|---|
| upgrade-guide | Timer wrappers return void in TypeScript and ignore calls after disposal. |
Timer wrapper return types and disposal
English | 中文
Change
The functions returned by ctx.throttle() and ctx.debounce() now declare a void return type. They previously inherited the callback's return type, although they already returned undefined at runtime. TypeScript code that uses the wrapper's return value or assigns it to the callback's type may need updating. Host and browser use the same TimerService implementation.
Calling .dispose() or disposing the owning fiber cancels pending work and makes later wrapper calls inert. A disposed throttle wrapper previously could still execute a leading call; debounce wrappers already ignored calls after disposal.
The @deepseek-ai/dsh-cordis-client-runner/client entry no longer exports ClientTimerService. The runner installs the shared TimerService from @deepseek-ai/cordis-plugin-timer.
Migration
- Let TypeScript infer the wrapper type, or declare its call signature with a
voidreturn type while retaining.dispose()where needed. - Consume callback results inside the callback. Awaiting the wrapper does not wait for an asynchronous callback to finish.
- Move required work before disposal, or create a new wrapper in an active plugin.
- Remove imports of
ClientTimerServicefrom the runner. Consumer plugins declareinject: ['timer']and usectx.timer; code that installs the service importsTimerServicefrom@deepseek-ai/cordis-plugin-timer. - Run your extension's type check and verify that calls after disposal neither invoke the callback nor schedule work.