Skip to content
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

QInput rules parameter has any type with Volar #11043

Closed
jlucaso1 opened this issue Oct 19, 2021 · 3 comments · Fixed by #11597
Closed

QInput rules parameter has any type with Volar #11043

jlucaso1 opened this issue Oct 19, 2021 · 3 comments · Fixed by #11597
Assignees
Labels

Comments

@jlucaso1
Copy link

Describe the bug
When I create an input with rules, the IDE (VSCode) show me this error:
Parameter 'val' implicitly has an 'any' type.ts(7006)
Example:
<q-input v-model="model" label="Required Field" :rules="[(val) => (val && val.length > 0) || 'Field is required!']" />

Platform (please complete the following information):
Quasar Version: 2.1.7
@quasar/app Version: 3.1.5

Thanks

@jlucaso1 jlucaso1 added the Qv2 🔝 Quasar v2 issues label Oct 19, 2021
@IlCallo
Copy link
Member

IlCallo commented Oct 20, 2021

Easy fix is to provide rules as functions instead of inlining them
Currently there's no way for TS to infer the val provided to the rule if you don't specify it manually, current tooling won't allow it but we'll keep an eye on this if in the future it will be possible (we know there's an ongoing effort from the Vue team on this)

@IlCallo IlCallo closed this as completed Oct 20, 2021
@yusufkandemir yusufkandemir self-assigned this Oct 26, 2021
@yusufkandemir
Copy link
Member

Currently rules is any[]. With better type definitions for rules prop(e.g. string | (value: any) => (string | true)), we can get rid of the TS error, because we are going to explicitly type the parameter as any. We still can't infer the correct type as @IlCallo said, but at least we will have better type definitions.

@yusufkandemir yusufkandemir reopened this Oct 26, 2021
rstoenescu pushed a commit that referenced this issue Dec 8, 2021
…11043) (#11597)

* feat(ts&api): Allow tsType for Array type

* feat(ts/use-validation): Greatly improve the 'rules' prop type
@rstoenescu
Copy link
Member

Enhancement will be available in Quasar v2.3.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants