Extend interfaces in Typescript
· ☕ 2 min read
Interface an interface. If that doesn’t excite you, I don’t know what will. We have seen interfaces used as types before. But as our God Goop says - “abstract; (while && when) you can;”. So, we are here to know about interfaces for interfaces. Consider this simple example - 1 2 3 interface Borg { name: string; } Now, any class implementing the interface Borg will have a name attribute.

Interfaces for Arrays in Typescript
· ☕ 2 min read
What exactly are interfaces for arrays? Previously we have seen interfaces as types. Interfaces provide useful abstraction on class and can be useful in tricky situations with complex types. But, what about interfaces for array? It turns out interfaces can be as easily applied for array types as well. They are just super useful as interfaces that define complex types and make arrays type-safe - nothing more, nothing less.

Anonymous functions in Typescript
· ☕ 2 min read
Let’s talk anonymous functions and make them, well, “not anonymous”. Anonymous functions are just functions without names. If you have been following this blog, or have written some Javascript - you surely would have come across them. Anonymous functions are just function expressions. Let’s see a quick example. The following code block has a ‘named’ function.

Abstract classes in Typescript
· ☕ 2 min read
Why and how of using abstract classes in Typescript. We have seen a bit of classes and objects in Typescript previously. There was however a key aspect of object oriented programming missing there. Although we discussed inheriting classes, we never mentioned abstract classes. Sacrilege, that. On the other hand, anything goes for the daily blogging gobble-gobble.

Crazy space utilization in VSCode
· ☕ 2 min read
Running out of space? You have VSCode and love tinkering with it? Then do this. Well the introductory line is cheesy and shows desperation for clicks. So, I had to have them. And - no, this is not even a secret. VSCode stays sane until it goes insane with storage space.

Non-number values for enum in Typescript
· ☕ 1 min read
Use non-numbers in Typescript enums. enums have the following typical definition and usage - 1 2 3 4 5 6 7 8 9 enum Colors { red, blue, green } console.log(Colors[1]); // blue Or, the numbers can be explicitly specified.. 1 2 3 4 5 6 7 8 9 10 11 12 enum Colors { red = 1, blue = 2, green = 3 } console.

Decorators in Typescript
· ☕ 2 min read
Decorate a class, member or property to signify its specialty. Decorators are not available in Javascript but enable us to enhance our Typescript libraries and code. Decorators are experimental features in Typescript at this time. A decorator is a way to annotate or modify a class, properties, functions or parameters. Decorator is specified against a target class, and has a body that indicates the decorator’s function.

Type casting in Typescript
· ☕ 5 min read
“Typecast types in Typescript” : that’s three “types” in a sentence with three significant words, and for that, I should tap out (but I don’t). We see a lot about “type assertions” in to type conversations (or conversions!) in Typescript. Type assertions enable you to override default type inference for neutral types.

Typing collections in Typescript
· ☕ 2 min read
How are collections typed in Typescript? Primitives are fairly easy to type - we have seen this while discussing Typescript and its types. 1 2 const num: number = 0; const msg: string = "hello"; We have seen examples of typed arrays in the same post, but how about all the other collections?

Three quick ways to convert objects to arrays
· ☕ 2 min read
Easily convert objects to arrays and iterate to your heart’s content. There are multiple ways of converting an object to an array (which, also is an object but a different one at that.) Method 1: A simple Object.values() method The first idea that comes to mind is to just use Object.

A Different IIFE Syntax
· ☕ 1 min read
Here’s a different syntax for our favourite IIFE’s. Immediately invoked function expressions enable us to write functions without using “functions”. Well - just kidding. They are functions but with a different syntax. A typical IIFE looks like this - 1 2 3 4 5 6 7 8 9 10 11 const x = 1, y = 9; var sum = 0; (function() { sum = x + y; console.

Commit to blog daily - it's smart and stupid
· ☕ 5 min read · ✍️ [prashanth]
Daily blogging by itself is not a bad thing. I changed tracks a year back to get back to development after a million years of doing something else. I thought through the idea of blogging daily, what I was going to write about, and how that would pan out through days and months.

Access modifiers in Typescript
· ☕ 2 min read
Typescript supports public, private and protected modifiers that affect the accessibility of class in different ways. Access modifiers further a core concept of object oriented programming - ‘encapsulation’. The accessibility of variables and members of a class are driven by modifiers and therefore controlled in the programming flow. Let’s start with a simple class example.