-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
[2.7.x] Here is a type error when using ref() on attribute 'ref' in TSX #12758
Comments
fix pr: #12759 :D |
I also had the same problem |
yep, but this PR has`t been merged yet, i dont know whether something wrong with the PR or not :( |
Had the same problem using ts and function-refs in vue 2.7.x. example:
|
When I intend to modify this pr to add funciton ref type, I found someone has already created the pr about this #12763 |
Even after these two fixes, the el in the function-ref example still hints that implicitly has type any. Writing functions directly in template can effectively use closures to access variables that are traversed by v-for. But it is not accessible in setup or methods options, so how should this problem be solved. |
I have updated my pr with fixing the function-refs type error. Defined type const fooRef = ref<HTMLElement>()
<div ref={(el) => {fooRef.value = el as HTMLElement}} /> its same as vue3. :D |
Version
2.7.10
Reproduction link
codesandbox.io
Steps to reproduce
Using type 'Ref' on ref will notice the error :
jsx.d.ts(1305, 3): The expected type comes from property 'ref' which is declared here on type 'ElementAttrs<HTMLAttributes>'
.In the
vue/types/jsx.d.ts
, the type ReservedProps only support type'String' in Vue2.7.x,but supporting type 'String'/'Ref'/'Function' in Vue3.xVue3 - jsx.d.ts
Vue2.7.x -jsx.d.ts
What is expected?
Using type 'Ref' on the property 'ref'.
What is actually happening?
The type 'ref' only support 'String | undefined'.
The text was updated successfully, but these errors were encountered: