typescript - Using types from Vue3-mq - Stack Overflow

The Vue3-mq plugin apparently supports TypeScript, but I don't seem to be able to actually use the

The Vue3-mq plugin apparently supports TypeScript, but I don't seem to be able to actually use the types in a Vue3 app.

We are installing the plugin in the "standard" way (according to the docs) and are injecting mq into SFC components like this inject: ['mq'], which works as expected.

However, we have TypeScript errors everywhere we are using it in a script block, e.g if we try to do this if (this.mq.smMinus) { ... } then we see a TypeScript error under smMinus that says "property smMinus does not exist on type unknown".

As mq becomes a property of this inside SFC files, I have tried adding the types to our env.d.ts file where we declare some other types under ComponentCustomProperties. These are some of the ways of importing the types I have tried:

import {Vue3Mq} from 'vue3-mq';
import {Vue3Mq} from 'vue3-mq/types';
import Vue3Mq from 'vue3-mq';
import Vue3Mq from 'vue3-mq/types';
import type Vue3Mq from 'vue3-mq';
import type Vue3Mq from 'vue3-mq/types';
import * as Vue3Mq from 'vue3-mq';
import * as Vue3Mq from 'vue3-mq/types';

None of these work (and I've tried all these variations with other things like import mq from 'vue3-mq' and import useMq from 'vue3-mq'), in that, if I hover over the imported token, it does not show me any type information at all for the plugin.

We are using other 3rd libs in the app without any problem at all. E.g, if I do this: import moment from 'moment';, when I hover on the imported moment token, I can see the type definition for the moment function, and when I use moment in an SFC file, I get full Intellisense for its methods.

How can I successfully import the types please? The absolute best I've been able to get is to type mq as any so that at least the errors in our SFC go away.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745628020a4636927.html

相关推荐

  • typescript - Using types from Vue3-mq - Stack Overflow

    The Vue3-mq plugin apparently supports TypeScript, but I don't seem to be able to actually use the

    8小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信