TypeScript

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.

Difference Between Array<Type>, Type[], [Type] in TypeScript

When defining an array in TypeScript you might think it is okay to define it using `[string]`. I have made this mistake several times & I find others making it often as well. This is actually defining a tuple, which is probably not the array you are wanting.

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