Member-only story
9 tricks that separate a pro Typescript developer from an noob 😎
Typescript is a must-know tool if you plan to master web development in 2025, regardless of whether it’s for Frontend or Backend (or Fullstack). It’s one of the best tools for avoiding the pitfalls of JavaScript, but it can be a bit overwhelming for beginners. Here are 9 tricks that will kick start your journey from a noob to a pro Typescript developer!
1. Type inference
Unlike what most beginners think, you don’t need to define types for everything explicitly. Typescript is smart enough to infer the data types if you help narrow it down.
// Basic cases
const a = false; // auto-inferred to be a boolean
const b = true; // auto-inferred to be a boolean
const c = a || b; // auto-inferred to be a boolean
// Niche cases in certain blocks
enum CounterActionType {
Increment = "INCREMENT",
IncrementBy = "INCREMENT_BY",
}
interface IncrementAction {
type: CounterActionType.Increment;
}
interface IncrementByAction {
type: CounterActionType.IncrementBy;
payload: number;
}
type CounterAction = IncrementAction | IncrementByAction;
function reducer(state: number, action: CounterAction) {
switch…