R
R
RokeAlvo2021-07-17 17:04:53
typescript
RokeAlvo, 2021-07-17 17:04:53

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;


Everything basically works, but at the place of use there is no information about the library or the components themselves. 60f2e2733c417074085651.png

How to configure the assembly of the library?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-07-17
@RokeAlvo

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 .vuedefault 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 question

Ask a Question

731 491 924 answers to any question