Skip to content

QInput rules parameter has any type with Volar #11043

Closed

Description

@jlucaso1

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

Activity

  1. IlCallo commented on Oct 20, 2021

    @IlCallo
    Member

    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)

  2. yusufkandemir commented on Oct 26, 2021

    @yusufkandemir
    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.

  3. added a commit that references this issue on Dec 8, 2021
    9579815
  4. rstoenescu commented on Dec 8, 2021

    @rstoenescu
    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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions