Skip to content

fix(runtime-core): prevent readonly warning when using useTemplateRef with same variable name as template ref#11802

Closed
jh-leong wants to merge 1 commit intovuejs:mainfrom
jh-leong:fix/11795
Closed

fix(runtime-core): prevent readonly warning when using useTemplateRef with same variable name as template ref#11802
jh-leong wants to merge 1 commit intovuejs:mainfrom
jh-leong:fix/11795

Conversation

@jh-leong
Copy link
Copy Markdown
Member

@jh-leong jh-leong commented Sep 4, 2024

close #11795

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Sep 4, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 100 kB (+187 B) 37.7 kB (+67 B) 33.9 kB (+24 B)
vue.global.prod.js 159 kB (+187 B) 57.6 kB (+54 B) 51.2 kB (+80 B)

Usages

Name Size Gzip Brotli
createApp 55.2 kB (+62 B) 21.2 kB (+27 B) 19.4 kB (+24 B)
createSSRApp 59.1 kB (+62 B) 22.9 kB (+27 B) 20.8 kB (+28 B)
defineCustomElement 59.9 kB (+62 B) 22.8 kB (+32 B) 20.7 kB (+21 B)
overall 68.9 kB (+62 B) 26.3 kB (+27 B) 23.9 kB (+6 B)

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Sep 4, 2024

Open in Stackblitz

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@11802

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@11802

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@11802

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@11802

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@11802

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@11802

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@11802

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@11802

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@11802

vue

pnpm add https://pkg.pr.new/vue@11802

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@11802

commit: 227bd9b

@edison1105 edison1105 added 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. ready for review This PR requires more reviews labels Sep 4, 2024
@linzhe141
Copy link
Copy Markdown
Member

linzhe141 commented Sep 4, 2024

If this is the case, Vue will still throw a warning
this pr - playground

I think we should check if it's a templateRef when setRef, but since vue has unref'd the templateRef, we can't determine it anymore

@jh-leong
Copy link
Copy Markdown
Member Author

jh-leong commented Sep 4, 2024

If this is the case, Vue will still throw a warning this pr - playground

I think we should check if it's a templateRef when setRef, but since vue has unref'd the templateRef, we can't determine it anymore

Good catch @linzhe141 !

However, for this edge case, maybe we could show a warning at compile time (as edison1105 suggested) or let the language tool handle it with a TypeScript error. In fact, the latest version of the language tool already provides warnings for such cases.

@yyx990803 yyx990803 closed this in bc63df0 Sep 4, 2024
@jh-leong jh-leong deleted the fix/11795 branch September 4, 2024 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. ready for review This PR requires more reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set operation on key "value" failed: target is readonly always warned with useTemplateRef

3 participants