Closed
Description
What problem does this feature solve?
When watching multiple sources you don't have to do explicit const assertion on the input array.
What does the proposed API look like?
Since TypeScript 4.0 and the ability to use generics in the tupel spread syntax, the sources
parameter in watch
can always be made a tupel type. Basically change the type of sources
from T
to readonly [...T]
:
function watch<
T extends Readonly<Array<WatchSource<unknown> | object>>,
Immediate extends Readonly<boolean> = false
>(
sources: T,
cb: WatchCallback<MapSources<T, false>, MapSources<T, Immediate>>,
options?: WatchOptions<Immediate>
): WatchStopHandle
// ----->
function watch<
T extends Readonly<Array<WatchSource<unknown> | object>>,
Immediate extends Readonly<boolean> = false
>(
sources: readonly [...T],
cb: WatchCallback<MapSources<T, false>, MapSources<T, Immediate>>,
options?: WatchOptions<Immediate>
): WatchStopHandle