diff --git a/.github/contributing.md b/.github/contributing.md index a64b89a2fcb..c9a08b7f633 100644 --- a/.github/contributing.md +++ b/.github/contributing.md @@ -244,7 +244,7 @@ Test coverage is continuously deployed at https://vue-next-coverage.netlify.app/ This project uses [tsd](https://github.com/SamVerschueren/tsd) to test the built definition files (`*.d.ts`). -Type tests are located in the `test-dts` directory. To run the dts tests, run `yarn test-dts`. Note that the type test requires all relevant `*.d.ts` files to be built first (and the script does it for you). Once the `d.ts` files are built and up-to-date, the tests can be re-run by simply running `yarn test-dts`. +Type tests are located in the `test-dts` directory. To run the dts tests, run `yarn test-dts`. Note that the type test requires all relevant `*.d.ts` files to be built first (and the script does it for you). Once the `d.ts` files are built and up-to-date, the tests can be re-run by simply running `yarn test-dts-only`. ## Financial Contribution diff --git a/packages/runtime-core/src/apiWatch.ts b/packages/runtime-core/src/apiWatch.ts index af54568823f..f5c48892a4b 100644 --- a/packages/runtime-core/src/apiWatch.ts +++ b/packages/runtime-core/src/apiWatch.ts @@ -86,7 +86,7 @@ export function watch< T extends Readonly | object>>, Immediate extends Readonly = false >( - sources: T, + sources: Readonly<[...T]>, cb: WatchCallback, MapSources>, options?: WatchOptions ): WatchStopHandle diff --git a/test-dts/watch.test-d.ts b/test-dts/watch.test-d.ts index 84c6e542b5a..d9f838581fd 100644 --- a/test-dts/watch.test-d.ts +++ b/test-dts/watch.test-d.ts @@ -10,12 +10,13 @@ watch(source, (value, oldValue) => { expectType(oldValue) }) +// const array and normal array will be treated equally watch([source, source2, source3], (values, oldValues) => { - expectType<(string | number)[]>(values) - expectType<(string | number)[]>(oldValues) + expectType<[string, string, number]>(values) + expectType<[string, string, number]>(oldValues) }) -// const array +// const array and normal array will be treated equally watch([source, source2, source3] as const, (values, oldValues) => { expectType>(values) expectType>(oldValues) @@ -34,13 +35,15 @@ watch( watch( [source, source2, source3], (values, oldValues) => { - expectType<(string | number)[]>(values) - expectType<(string | number | undefined)[]>(oldValues) + expectType<[string, string, number]>(values) + expectType<[string | undefined, string | undefined, number | undefined]>( + oldValues + ) }, { immediate: true } ) -// const array +// const array and normal array will be treated equally watch( [source, source2, source3] as const, (values, oldValues) => {