You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
QInput rules parameter has any type with Volar #11043
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
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)
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.
Activity
IlCallo commentedon 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)
yusufkandemir commentedon Oct 26, 2021
Currently
rulesisany[]. With better type definitions forrulesprop(e.g.string | (value: any) => (string | true)), we can get rid of the TS error, because we are going to explicitly type the parameter asany. We still can't infer the correct type as @IlCallo said, but at least we will have better type definitions.feat(ts/use-validation): Greatly improve the 'rules' prop type (fix: #…
rstoenescu commentedon Dec 8, 2021
Enhancement will be available in Quasar v2.3.5