v-mask
v-mask copied to clipboard
We need @types definitions for Typescript
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
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);
The trick is simply to follow this stackoverflow answer
https://stackoverflow.com/a/50516783/3949805
One year of this. Where are the typescript defs?
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;
}
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!