[Vuejs]-Typescript not working in vue SFC

0👍

I hope you are using vue-loader or something similar to be able to write single-file components(SFCs) in the first place.

This sfc.d.ts should be renamed to a vue.shims.d.ts or index.d.ts where type definitions are held. You don’t need to import this file anywhere. Typescript will use it this whenever it encounters a .vue file
Now you can create an SFC with lang attribute set to ts.

<script lang="ts">
import Vue from "vue";

export default Vue.extend({

Here is a Microsoft Doc that explains the same. In our project, I have defined it as index.d.ts.

Leave a comment