-
Notifications
You must be signed in to change notification settings - Fork 141
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
[BUG] v-model when props has attr required: true
, typescript report errors.
#636
Comments
@chaozwn, can you provide code of |
import { CellGroup, Dialog, Field, Switch } from "vant"; const SchedulerDialog = defineComponent({ <Dialog title={"Detail"} v-model:show={props.showDialog.show} onConfirm={handleOnConfirm} > <Field v-model={task.value.content} name={"content"} label={"内容"} rules={[{ required: true, message: "内容不能为空" }]} /> <Field v-model={task.value.createTime} name={"createTime"} label={"创建时间"} disabled /> <Field name={"status"} label={"状态"} disabled> {{ input: () => ( <Switch v-model={task.value.status} size={"20px"} /> ), }} ); }, }); export default SchedulerDialog; |
|
but it works in vue template. i think it should not be throw a TSLint problem right? |
in typescript,when props has |
TSLint? As far as I know it is depricated. So, vue templates work very bad with ts. |
You can check here an example of component with |
This problem should be solved, instead of avoiding it using methods such as |
|
I created a PR vue-macros/vue-macros#494 to resolved it. // tsconfig.json
{
"vueCompilerOptions": {
"target": 3,
"plugins": [
"@vue-macros/volar/jsx-directive"
// ...more feature
]
}
} |
I also face the same problem, how should I solve it |
https://vue-macros.dev/guide/bundler-integration.html You can install pnpm add @vue-macros/volar Usage // tsconfig.json
{
"vueCompilerOptions": {
"plugins": [
// ...
"@vue-macros/volar/jsx-directive"
]
}
} |
Thank you ! |
You can use // without 'on' prefix
defineEmits([ 'update:rowData'])
// Or
defineModel('rowData') If the issue still unresolved, please provide a minimal repository. |
const emit = defineEmits<{ |
Type declaration should also be possible, if not, please provide a minimal repository. |
@zhiyuanzmj see https://github.com/lixiaofa/test636/blob/main/vite.config.ts step: |
Thank's for your repository, It seems to be caused by VueMacros({
shortEmits: true,
plugins: {
vue: vue(),
vueJsx: vueJsx() // 如果需要
}
}), |
It doesn't seem to be effective |
Sorry, It's be caused by 'betterDefine', waiting for merge vue-macros/vue-macros#582. |
Okay, thank you for your help |
Are there any workarounds for this not tied to Vue Macros? We use VS2022 instead of VSCode so cannot use it. |
🐛 Bug description
v-model when props has attr
required: true
, typescript report errors.link: #151
🏞 Desired result
🚑 Other information
The text was updated successfully, but these errors were encountered: