v-mask icon indicating copy to clipboard operation
v-mask copied to clipboard

We need @types definitions for Typescript

Open jshamg opened this issue 4 years ago • 5 comments

Hi,

We really want to use this instead of vue-the-mask but it seems like they are the only ones with types definitions. It would be awesome if wen can get that for v-mask, too. Thanks in advance!

-Josh

jshamg avatar Jul 03 '20 07:07 jshamg

Is there any way to get an interim solution so the following config code will work. Otherwise, are there any config tricks that can help us TypeScript users? We're kind of hard broke right now.

// filename: v-mask.config.ts
import Vue from 'vue';
import VueMask from 'v-mask'; // <== Error: TS7016 (TS) Could not find a declaration file for module 'v-mask'. 
                              // '.../node_modules/v-mask/dist/v-mask.js' implicitly has an 'any' type.

Vue.use(VueMask);

rashadrivera avatar Mar 21 '21 01:03 rashadrivera

The trick is simply to follow this stackoverflow answer

https://stackoverflow.com/a/50516783/3949805

Armaldio avatar Mar 21 '21 15:03 Armaldio

One year of this. Where are the typescript defs?

AlenDavid avatar Apr 19 '21 03:04 AlenDavid

You can add a v-mask.d.ts file in your project, such as :

declare module 'v-mask' {
  import { DirectiveHook } from 'vue';

  interface VueMaskDirectiveType {
    bind: DirectiveHook;
    componentUpdated: DirectiveHook;
    unbind: DirectiveHook;
  }
  export const VueMaskDirective: VueMaskDirectiveType;
}

ndup0nt avatar Jul 21 '21 14:07 ndup0nt

The directive d.ts example works great, but I'm having trouble wiring up the filter. Is that documented anywhere? I would like to use {{ phone | VMask("(###) ###-###") }}

TYIA!

agersea avatar Apr 23 '22 17:04 agersea