When working in VSCode, Typescript is highlighting an error in the file src/main.ts
. However, when I run the project, it executes without any errors or warnings.
https://i.sstatic.net/pybuM.png
The configuration in my tsconfig file is as follows:
{
"compilerOptions": {
"outDir": "dist",
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"],
"baseUrl": "src",
"allowJs": true,
"paths": {
"@/*": ["./*"],
"~/*": ["./*"]
},
"suppressImplicitAnyIndexErrors": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"exclude": ["node_modules", "dist"]
}
I have a file named App.vue
located at src/App.vue
with the following content:
<template>
<div>
<!-- <h1 v-if="showModal">HELLO WORLDDNIOAS</h1> -->
<!-- <SignInModal :show-modal="showModal" /> -->
<HomePage />
<!-- <router-view></router-view> -->
</div>
</template>
<script lang="ts">
import { defineComponent, computed, ref } from "vue";
import HomePage from "@/components/HomePage.vue";
import SignInModal from "@/components/SignInModal.vue";
import Test from "@/components/Test.vue";
import { useStore } from "vuex";
export default defineComponent({
name: "App",
components: {
HomePage,
SignInModal,
Test,
},
setup() {
const store = useStore();
const hello = ref(false);
return {
showModal: computed<boolean>(
() => store.getters["modal/showModal"]
),
hello,
};
},
});
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
}
</style>
In addition, I have included type definitions in the file shims-vue.d.ts
as shown below:
import Vue, { DefineComponent } from "vue";
declare module "*.vue" {
//eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>;
export { component, Vue };
}
Despite everything running smoothly and displaying correctly, why is VSCode indicating that there is an error?