Skip to content

Typescript inferred types for child components that has done type checking #2262

Closed Answered by guypassy
Lilja asked this question in Help and Questions
Discussion options

You must be logged in to vote

The issue doesn't stem from Pinia here, rather from the fact that because you have this code in the Child component, there is nothing to indicate to typescript that the value is populated. You could just as well use this component elsewhere and not have that check.
If you are truly certain that the component won't be used elsewhere and the username will therefore always be populated, a simpler way to appease typescript would be to use the ! to mark it as definitely having a value => username.value!.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@posva
Comment options

@Lilja
Comment options

Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants