I'm a beginner with TypeScript (Day 1), but have worked on above average JavaScript projects. I'm looking for advice about some "best practices" and standards when it comes to declaring or assigning types in code. At the moment, I find myself doing it for literally everything which is essentially making my code unreadable.
For example, consider this:
import {createApp, DefineComponent} from 'vue'
import {createRouter, createWebHistory, Router, RouteRecordRaw, RouterHistory} from 'vue-router'
import NPage from '~/layouts/N-Page.vue'
const router : Router = createRouter({
history: <RouterHistory>createWebHistory(),
routes: <RouteRecordRaw[]>[{
component: <DefineComponent>NPage,
name: <string>'home',
path: <string>'/',
}]
})
createApp(NPage).use(router).mount('#app')
This is a simple main.ts setup for Vue.js. Now, my IDE (IntelliJ IDEA), was able to determine the type for router by itself. However, I went ahead and declared the type explicitly. Same with history, routes, etc. What's worse, I find myself declaring type for each individual property too (component, name, path).
This is getting really messy, really fast. And by the looks of it, I can assume, this is not how it's done. In this case, could someone point out, how exactly to make decisions about what we need to declare/assign types for and what not?