Closed paveloom closed 3 days ago
Yes, It is a duplicate of #6882.
But it doesn't seem to be an issue with vue
or language-tools
, because the type hints for modal.value
and close
are correct. It seems more like a problem with typescript-lint
.
Vue version
3.5.13
Link to minimal reproduction
https://github.com/paveloom-o/vue-playground/tree/use-template-ref
Steps to reproduce
1)
git clone --branch use-template-ref https://github.com/paveloom-o/vue-playground.git
2)cd vue-playground
3)direnv allow
(OPTIONAL: if you havedirenv
andnix-direnv
installed) 4)npm install
5)npm run lint
What is expected?
No errors should be reported.
What is actually happening?
The following errors are reported:
System Info
Any additional comments?
App.vue
```vue
Modal.vue
```vue
The intent is to use the exported functions from an instance of the
Modal
component whenever needed. For that, I use Vue'suseTemplateRef
function and thedefineExpose
compiler macro.Note that there are two functions exported from the
Modal
component, namely,open
andclose
. However, I use these functions differently in theApp
component. Theopen
method is used directly in thetemplate
section, whereas for theclose
function I've created a wrapper of the same name in thescript setup
section. Note that the error of using anany
value is reported only on the wrapper (specifically, on the callmodal.value?.close()
).This issue is also eerily similar to https://github.com/vuejs/core/issues/6882.