When starting a Vue project with typescript, you will notice that there are two declaration files included: shims-vue.d.ts
and shims.tsx.d.ts
.
//shims-vue.d.ts
declare module "*.vue" {
import Vue from 'vue';
export default Vue;
}
Additionally:
//shims-tsx.d.ts
import Vue, { VNode } from 'vue';
declare global {
namespace JSX {
// tslint:disable no-empty-interface
interface Element extends VNode {}
// tslint:disable no-empty-interface
interface ElementClass extends Vue {}
interface IntrinsicElements {
[elem: string]: any;
}
}
}
Interestingly, when I was working on a small project without using the Vue CLI, I forgot to include the second file (shims.tsx.d.ts
) and surprisingly, my project compiled and ran smoothly without any errors.
I came across this discussion on the topic: https://github.com/vuejs/vue-cli/issues/1198, but I am still seeking more clarification.
I am curious about the purpose of this file and why it is included by default. Essentially, what consequences would I face if I choose not to include this declaration file?
Your insights are appreciated!