-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Initial value when typing Template Refs #1950
Unanswered
FloEdelmann
asked this question in
Q&A
-
In TypeScript with Composition API → Typing Template Refs, it is recommended to use an explicit initial value of null
:
const el = ref<HTMLInputElement | null>(null) // type: Ref<HTMLInputElement | null>
Why not simplify it to leverage the implicit undefined
instead?
const el = ref<HTMLInputElement>() // type: Ref<HTMLInputElement | undefined>
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment