4

I'm trying to learn Vue and Typescript. But I can't seem to set it up correctly.

I made an app.ts file with these lines of code:

import { Vue } from "../libs/vue/vue";

var app = new Vue({
    el: "#app",
    data: {
        message: 'Hello Vue!'
    }
}); 

I thought this would compile to something like this:

var app = new Vue({
  el: '#app',
  data: {
    message: 'Hello Vue!'
  }
})

But instead I'm getting tons of errors when I run tsc. It seems as if it is trying to build the Vue definition files? Image here

How can I get started working on Vue then with typescript? Are there any tutorials that can help me with this? I found a few online but none seem to be helping, or they are using other libraries such as av-ts which gives me the same problem

1 Answer 1

2

This is the official document.

https://v2.vuejs.org/v2/guide/typescript.html

Also, why are you importing Vue from "../libs/vue/vue"? That may be the cause of the problem. If you have installed Vue.js with npm install vue, you should write

import Vue = require('vue');

or

import * as Vue from 'vue';
Sign up to request clarification or add additional context in comments.

2 Comments

I tried what you said but it still gives me errors with the .d.ts files
Oh I found the problem. After checking the detailed MsBuild logs I saw VS was using Typescript 1.8. So after installing Typescript 2.1.4 it worked!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.