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

Type inference of useTemplateRef won't work if there're leading whitespaces. #4828

Closed
g-plane opened this issue Sep 9, 2024 · 0 comments · Fixed by #4829
Closed

Type inference of useTemplateRef won't work if there're leading whitespaces. #4828

g-plane opened this issue Sep 9, 2024 · 0 comments · Fixed by #4829
Labels
bug Something isn't working 🔩 p2-edge-case

Comments

@g-plane
Copy link
Contributor

g-plane commented Sep 9, 2024

Vue - Official extension or vue-tsc version

2.1.6

VSCode version

1.92

Vue version

3.5

TypeScript version

5.5

System Info

No response

package.json dependencies

No response

Steps to reproduce

Given the example below:

<script setup lang="ts">
import { useTemplateRef } from 'vue'

const ref1 = useTemplateRef('input')
const ref2 = useTemplateRef( 'input')
</script>

<template>
  <input ref="input">
</template>

Note that there're additional whitespaces before ref name in the second useTemplateRef call.

What is expected?

Type inference of both useTemplateRefs works.

What is actually happening?

  • Type inference of the first useTemplateRef works, which can obtain attributes of <input> element.
  • The second one doesn't work. It gets unknown.

Link to minimal reproduction

No response

Any additional comments?

Trailing whitespaces after ref name won't cause this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🔩 p2-edge-case
Projects
None yet
2 participants