-
-
Notifications
You must be signed in to change notification settings - Fork 438
vue 2.7 template type check for inline function #1654
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
Solved by disabling both ts and prettier @input="
// @ts-ignore
// prettier-ignore
(val) => doSomething(index, val)
" this method is not worked, prefer the below one |
I think it shouldn't trigger the |
It's just a demo. In the actual case, |
I see. Instead of
, where |
Oh, I didn't think of it. Thanks! |
on: {
"command": function($event) {
_vm.anyFn((val) => _vm.doSomething(index, val))
}
}
// which should be
on: {
"command": (val) => _vm.doSomething(index, val)
} |
Try |
It won't work, |
Isn't |
You are right, but again, real world case is mush more complicated, like multiple arguments I ended up modify the change this line to Considering whether to make it a PR or not |
try use <template>
<div v-for="(item, index) in arr" :key="index">
<input type="text" :value="item" @input="doSomething(index, $event)" />
</div>
</template> |
|
Why they don't support |
|
Maybe you should create a bug in prettier —— add leading semi colon will break vue event listener |
Not only the leading semi problem. |
Maybe also create an issue for vue 2.7 and vue 3. |
That's what I'm thinking about. |
Can you reproduce this problem in https://github.com/johnsoncodehk/volar-starter/tree/vue2? |
My bad, I've updated code snippet, using |
Can you provide me a demo repo? |
check this |
Use this fix temporarily: // file: components.d.ts
declare module "element-ui/types/input" {
interface ElInput {
$props: {};
$emit: {
(event: "input", val: string, maybeAnother: number): void
}
}
declare module "vue" {
interface GlobalComponents {
ElInput: typeof import("element-ui/types/input").ElInput;
}
}
export {}; |
We can create a PR for element-ui types latter |
Thanks |
For late-comers like me, the <el-input type="text" :value="item" @input="(val) => doSomething(index, asAny(val))" /> const asAny = (val: any) => val |
I'm using vue 2.7 with TypeScript
As code shown above, the problem is
@input="(val) => doSomething(index, val)"
part.Parameter 'val' implicitly has an 'any' type.
sincenoImplicitAny
intsconfig
was enabledts-ignore
will causingprettier
add leading semi colon which is not valid attribute valueval
is an argument so asAny magic won't workAny workaround I can do?
The text was updated successfully, but these errors were encountered: