Answer the question
In order to leave comments, you need to log in
How to import types from vue library?
There is a library project:
//package.json
{
"name": "rokealvo-lib",
"version": "0.1.0",
"private": true,
"main": "dist/rokealvo-lib.common.js",
"scripts": {
"build": "vue-cli-service build --target lib --name rokealvo-lib src/lib.ts",
},
}
//src/lib.ts
import Input from "@/components/VInput.vue";
import Button from "@/components/Button.vue";
import Complex from "@/components/VComplex.vue";
export const VInput = Input;
export const VButton = Button;
export const VComplex = Complex;
Answer the question
In order to leave comments, you need to log in
Alas, vue-cli does not do this out of the box. And when I last looked in this direction (a couple of years ago) - there were no plugins for this either. 2 years is a long time, so I recommend to google it.)
But here is another snag, which also needs to be taken care of in advance: the .vue
default type of imported files is simply Vue
, without specifying properties and other things. To have normal ts-types, they must be generated separately. There is a vuedts library for this , it's not perfect, but it does the job.
If you don’t find ready-made solutions, you can make something of your own with this either.)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question