Using vue-cli-service with typescript

Asked by At

I have a Vue project that I created with the Vue CLI, and I now want to enable TypeScript on the project. I took a look at this guide, but it recommends adding a Webpack config and replacing vue-cli-service in the package.json scripts section with Webpack.

Is there any way I can continue to use vue-cli-service to build my Vue app and enable TypeScript support for it?

3 Answers

0
Qwertie On Best Solutions

I ended up generating a new vue project using vue cli with typescript enabled and copied the tsconfig and added the packages missing in my package.json

0
thedanotto On

In vue-cli 3.x

$ vue create <app_name>

This will bring up a prompt, select Manually select features, enable TypeScript using the space bar. It will automatically configure everything for you.

0
tony19 On

With an existing Vue CLI project, you can add TypeScript support by entering this command:

vue add typescript

Beware that this command will overwrite files, but you can use git diff to view the differences.