Skip to content
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

feat(types): add type TemplateRef #12645

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Shinigami92
Copy link
Contributor

This adds "just" a type-alias so we can reduce some code when defining a template-ref.

Right now we would need to write code like:

import { useTemplateRef, type ShallowRef } from 'vue'
const myRef: Readonly<ShallowRef<typeof MyComp>> = useTemplateRef('myRef')

With the change we can reduce that to:

import { useTemplateRef, type TemplateRef } from 'vue'
const myRef: TemplateRef<typeof MyComp> = useTemplateRef('myRef')

This makes the code also a little bit more easier to read for newcomers to the project.

I use lefthandside types very often because this ensures that what the developer is wanted to receive here instead of just type what is there. A bit like ts eslint explicit-module-boundary-types

Copy link

github-actions bot commented Jan 3, 2025

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 100 kB 37.9 kB 34.2 kB
vue.global.prod.js 158 kB 57.8 kB 51.4 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.3 kB 18.2 kB 16.6 kB
createApp 54.2 kB 21.1 kB 19.3 kB
createSSRApp 58.4 kB 22.9 kB 20.8 kB
defineCustomElement 59.1 kB 22.7 kB 20.7 kB
overall 68.3 kB 26.3 kB 23.9 kB

Copy link

pkg-pr-new bot commented Jan 3, 2025

Open in Stackblitz

@vue/compiler-core

npm i https://pkg.pr.new/@vue/compiler-core@12645

@vue/compiler-dom

npm i https://pkg.pr.new/@vue/compiler-dom@12645

@vue/compiler-ssr

npm i https://pkg.pr.new/@vue/compiler-ssr@12645

@vue/compiler-sfc

npm i https://pkg.pr.new/@vue/compiler-sfc@12645

@vue/reactivity

npm i https://pkg.pr.new/@vue/reactivity@12645

@vue/runtime-core

npm i https://pkg.pr.new/@vue/runtime-core@12645

@vue/runtime-dom

npm i https://pkg.pr.new/@vue/runtime-dom@12645

@vue/server-renderer

npm i https://pkg.pr.new/@vue/server-renderer@12645

@vue/shared

npm i https://pkg.pr.new/@vue/shared@12645

vue

npm i https://pkg.pr.new/vue@12645

@vue/compat

npm i https://pkg.pr.new/@vue/compat@12645

commit: 3f7e6ca

@edison1105 edison1105 added scope: types 🧹 p1-chore Priority 1: this doesn't change code behavior. ready to merge The PR is ready to be merged. labels Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧹 p1-chore Priority 1: this doesn't change code behavior. ready to merge The PR is ready to be merged. scope: types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants