Filter By:

folder Typescript

TypeScript - Interpolated Strings

today

Coming from the .NET world String.Format() was by far my most used function for generating user readable error / log messages. After jumping over to TypeScript, I was bummed to learn that no similar function existed. However, it wasn’t so bad, after all console.log() allows us to pass multiple parameters and has no trouble logging them. let foo = { bar: 1 }; console.log("Foo is ", foo); //Prints: Foo is Object { bar : 1 } But this only covers one of the many use cases I used String. Read more...

TypeScript - Events

today

Intro If you were expecting a phone call from a friend, you (hopefully) wouldn’t sit by the phone and continuously pick it up to see if your friend was on the other end. Instead, you’d wait to be notified of an incoming call when the phone started ringing or vibrating. Sitting by the phone and picking it up over and over again is a form of what’s known as polling. Read more...

TypeScript - Taking The Magic Out of Magic Strings

today

What’s so Magical About Magic Strings? Magic strings are string literals strewn about a code base that apply some kind of limitation to the code. They can be used to filter valid input, constrain parameters, or control the behavior of code. They are often considered an anti-pattern due to how to they introduce the potential for bugs when typos occur, or by the difficulty they create when the need to change a magic string occurs. Read more...

TypeScript - How To Set Up A New Project

today

Summary For beginners TypeScript is like the carrot on the end of the stick, always just out of reach no matter how hard you try. Everyone touts how it’s “JavaScript that scales”, and once you use it you’ll never go back. But finding a decent tutorial on how to set up a new TypeScript project is quite the challenge. Many tutorials are out-dated and want you to install other packages such as gulp, jump through hoops, or even sacrifice your first born child (okay maybe not but still). Read more...