Skip to content

types(watch): watch array callback params type tuples #912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(types): watch array callback params type tuples
  • Loading branch information
a145789 authored Mar 7, 2022
commit 325f2d4a3b355e1b7f0c12115777098c8b48e4b5
2 changes: 1 addition & 1 deletion src/apis/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ export function watch<
T extends Readonly<WatchSource<unknown>[]>,
Immediate extends Readonly<boolean> = false
>(
sources: T,
sources: [...T],
cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>,
options?: WatchOptions<Immediate>
): WatchStopHandle
Expand Down
4 changes: 2 additions & 2 deletions test-dts/watch.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ watch([source, source2, source3], (values, oldValues) => {
})

// const array
watch([source, source2, source3] as const, (values, oldValues) => {
watch([source, source2, source3], (values, oldValues) => {
expectType<Readonly<[string, string, number]>>(values)
expectType<Readonly<[string, string, number]>>(oldValues)
})
Expand All @@ -42,7 +42,7 @@ watch(

// const array
watch(
[source, source2, source3] as const,
[source, source2, source3],
(values, oldValues) => {
expectType<Readonly<[string, string, number]>>(values)
expectType<
Expand Down
2 changes: 1 addition & 1 deletion test/v3/runtime-core/apiWatch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('api: watch', () => {
const status = ref(false)

let dummy
watch([() => state.count, status] as const, (vals, oldVals) => {
watch([() => state.count, status], (vals, oldVals) => {
dummy = [vals, oldVals]
const [count] = vals
const [, oldStatus] = oldVals
Expand Down