vuejs / composition-api

Composition API plugin for Vue 2
https://composition-api.vuejs.org/
MIT License
4.19k stars 343 forks source link

invalid type inference in `watch([ref] as const)` since 1.4.10 #924

Closed jacekkarczmarczyk closed 2 years ago

jacekkarczmarczyk commented 2 years ago

edit - I see that as const can be now removed, but shouldn't it still work with as const like it did in previous versions? Also this change was not announced in the release notes or changelog

repro

https://github.com/jacekkarczmarczyk/composition-api-ts-bug

run yarn build

code

<script setup lang="ts">
import { ref, watch } from '@vue/composition-api';

const foo = ref('');
watch([foo] as const, ([foo]) => {
  console.log(foo.length);
})
</script>

error

$ vue-tsc --noEmit && vite build
src/App.vue:6:19 - error TS2339: Property 'length' does not exist on type 'Ref<string>'.

6   console.log(foo.length);
                    ~~~~~~

image