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

ValidationRule typescript error #11854

Closed
3 of 20 tasks
Quimy opened this issue Jan 1, 2022 · 0 comments
Closed
3 of 20 tasks

ValidationRule typescript error #11854

Quimy opened this issue Jan 1, 2022 · 0 comments
Assignees
Labels
area/typescript bug/2-confirmed We have reproduce the problem and confirmed that this is a bug. Qv2 🔝 Quasar v2 issues

Comments

@Quimy
Copy link

Quimy commented Jan 1, 2022

I added promise as a validation rule on q-input and type check returns error:

Type '(((val: string) => string | true) | ((val: string) => Promise<string | boolean>))[]' is not assignable to type 'ValidationRule<any>[]'. Type '((val: string) => string | true) | ((val: string) => Promise<string | boolean>)' is not assignable to type 'ValidationRule<any>'. Type '(val: string) => Promise<string | boolean>' is not assignable to type 'ValidationRule<any>'. Type '(val: string) => Promise<string | boolean>' is not assignable to type '(value: any) => string | boolean'. Type 'Promise<string | boolean>' is not assignable to type 'string | boolean'. Type 'Promise<string | boolean>' is not assignable to type 'true'.

In my opinion type definition is missing a Promise:

export type ValidationRule<T = any> = EmbeddedValidationRule | ((value: T) => boolean | string);

Documentation mentions that Promise as a rule is possible: https://quasar.dev/vue-components/input#example--async-rules

Is this a thing or am I missing something?

Quasar Version: 2.4.1

Quasar mode:

  • SPA
  • SSR
  • PWA
  • Electron
  • Cordova
  • Capacitor
  • BEX
  • Vite Plugin

Additonal Info:

  • Typescript
  • SFC usage with <script setup>
  • Vuex
  • Prettier (eslint)
  • Standard (eslint)

Tested on:

  • SPA
  • SSR
  • PWA
  • Electron
  • Cordova
  • Capacitor
  • BEX

OS: Linux
Browsers: Electron

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/typescript bug/2-confirmed We have reproduce the problem and confirmed that this is a bug. Qv2 🔝 Quasar v2 issues
Projects
None yet
Development

No branches or pull requests

4 participants