beholdr / maska

Simple zero-dependency input mask for Vue, Svelte, Alpine.js and vanilla JS.

Home Page:https://beholdr.github.io/maska/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typescript/Vue directive argument types

jssuttles opened this issue · comments

Describe the bug

Following #97, when v-maska:[options] is used, the types on the vue directive expects arguments of the directive to be a string and not an object.

Error as follows:

ERROR in ***path/***componentname.vue.ts(226,40)
      TS2322: Type '{ mask: string; }' is not assignable to type 'string'.

When used as follows:

<v-text-field
  v-maska:[componentMask]
/>

const componentMask = reactive({
  mask: '######',
});

Could this be simplified and have the options moved/copied into the value?

I’m afraid not, because directive value works as binded value object.

Ok. Does the problem make sense and do you have any suggestions?

(This is the closest package that I've found that works for the most part.)

Nothing comes to mind at the moment, unfortunately. Official vue docs show dynamic argument passing <div v-example:[arg]="value"></div>, but tells nothing about type of the argument.

I'll close this issue for now, but if this could be given a bit of thought, I'm sure there would be others that would also be grateful

Thanks, I'll think about it. To be honest, I don't like having two different ways of setting options. Аnd placing options with binded value in the same object too.