DEV Community

Lakshya Khera
Lakshya Khera

Posted on

Vue + Typescript = 🔥

So, I wrote an article about Vue using Typescript on Medium link, so thought to write about it here.

I am a huge fan of Vue and recently I joined as an intern at an organisation where they're using Vue + Typescript so after a week of hustle, I finally have an idea how to get started.

So Vue + typescript works on class-based components, and use decorators to add functionality in class, to get started let's build a simple component.

We used Component decorative from 'vue-property-decorator' and used it over the class which extends Vue and exported it.

What about the state, well we can add an attribute and it will work as an state property.

Now let's add props and a child component.

Here, we used Prop decorator and simply added to an attribute in the component, and with the power of typescript's static typing, I can add datatype as well.

Now, in the component decorator, we can add components property where child components can be registered.

I talked briefly talked over other decorators over my medium article, and here I'm adding a link for a practice project I build using vue + typescript. Link.

Top comments (0)