JavaScript

Use Sass Variables In Typescript & Javascript

Having one true source of data is one of the first golden rules in software development. When creating components in JavaScript, you may want to add styles and classes that are also in your scss files. In an ideal world, you want to be able to make changes to these styles in one place and let your code update the rest.

How to use Default Props in React with TypeScript

Adding default props in React with TypeScript has been a pain. TypeScript 3 is making this process simple.

Use a TypeScript Definition Without Importing

There may come a time where you want to reference types in your TypeScript file without importing the code. This is common if you have a script tag somewhere else that is importing JavaScript from a public CDN of a popular library.

Why is TypeScript Adding Class Comments to my Code

I noticed all my TypeScript compiled files had been modified after a recent change. I hadn't changed anything in them so this gave me some concern. What I found was TypeScript added a /** @class */ comment to the modified files.

Adding Optional Parameters to a Javascript Function

Here's a great pattern for adding optional values to a function in JavaScript.

The Power of Destructuring in JavaScript

In my free time, I've been messing around with a functional programming language built for the Erlang VM called Elixir. One of my favorite features of Elixir is pattern matching. As of ES6, we now have some pattern matching features in JavaScript. One of those is destructuring. Using destructuring will simplify your code & make it more readable.

TypeScript Cannot Invoke an Expression whose Type Lacks a Call Signature

I have a love|hate relationship with TypeScript. I love it when it works & hate it when it doesn't do what I think it should. I was trying to clean up some code and wrote the following

Using Ternary Operators in ES6 String Templates

The new ES6 version of JavaScript introduced Template Strings which allow for improved readability of code when working with multiple line strings.