-
-
Notifications
You must be signed in to change notification settings - Fork 596
Template interpolation incorrect type on event (Typescript) #2504
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
Comments
This is the correct behavior. The handler of the |
So the |
|
Good point I guess. It should theoretically not be possible to trigger the event handler if |
That's true for Typescript, but does Vue work the same? Since I put |
@ktsn what do you think about this? |
I've been thinking of this problem and there seem to be two approaches:
if (vm.foo.bar.baz) {
const __foo = vm.foo
const __foo_bar = vm.foo.bar
const __foo_bar_baz = vm.foo.bar.baz
{
on: {
input: $event => func(__foo_bar_baz)
}
}
} The latter approach should be easier than the former but I'm not sure if it actually works properly. There might be some edge cases that I'm not aware of. |
I think we can choose the latter one. |
I will close this issue. |
Duplicate of #1212 |
Vetur: Restart VLS
Info
Problem
Vetur is reporting false error with
"vetur.experimental.templateInterpolationService": true
due to inccorect typing when passing a variable from an event, example:<!-- foo is computed property with return type number | undefined --> <div v-if="foo"> <!-- foo now should be number --> {{ foo }} <!-- Correct type (number) --> <input :example="foo" /> <!-- Also correct type (number) --> <input type="text" @input="bar(foo)" /> <!-- Incorrect type (number | undefined) --> </div>
Reproducible Case
The text was updated successfully, but these errors were encountered: