Blog Page 2

Forbidden Typescript: ensuring all of a type

When creating more complex systems, there are times where you will want to ensure that an array contains every value of a defined type. We have a union of primitive literal types to define the possible values a type can have:

Smart Contract Security

The crypto craze has died down, but if you are working on Smart Contracts or thinking about creating a new blockchain projects, security is a huge part of making sure the project is successful. Since Smart Contracts often interact with cryptocurrencies, blockchain assets, or other tokens, it’s important to make sure the Smart Contract is secure and follows best practices.

Forbidden Typescript: Get Class Name

We don’t get a lot of information using typeof in JavaScript or TypeScript. At most, it tells us whether a value is undefined, number, string, or object. If you want to get the class name using a function, you can use the following extended version of classOf that is originally from ā€œJavaScript: The Definitive Guideā€:

Forbidden Typescript: Enumerating Properties

In ā€œJavaScript: The Definitive Guideā€, there are functions described in 6.5 Enumerating Properties that probably shouldn’t be used in production code because they modify their input parameters: extend, merge, restrict, and subtract.

Forbidden Typescript: Using Object.create to clone

In ā€œJavascript: The Definitive Guideā€ there is an example that uses Object.inherit to inherit the prototype change. JavaScript defines a method Object.create that creates a new object using the given argument as the prototype of that object. Translating the examples from The Definitive Guide to Typescript, it looks like:

Data on the Wire

Back when Meteor was in vogue, they popularized the concept of ā€œData on the wireā€. This was the idea that the UI would be updated with changes from the dataset it is subscribed to.

Component Library Checklist

The following is a checklist I like to use to ensure I'm covering all the bases when building a component library. It's a work in progress, but I hope it can be useful to others.

Debugging slow tsc

I was working on a project and I noticed the tsc check that we ran on pre-commit hooks had become dramatically slower. I was seeing near instant times to type check the entire project go to agonizingly slow minutes to check the project. I was able to narrow the range of commits to some change we made within a month window. I’m sure I could have narrowed it down by continuing to git bisect and re-running time npx tsc, but it was much easier to just check out main and try out the following:

ChatGPT, Coding, and Language

I’ve been experimenting with ChatGPT, just like everyone else. But why has it become so popular? It truly is a revolutionary piece of technology. Is it The Next Big Thing? Will it really replace all of us?

Backend for Frontend

The Backend for the Frontend (BEFFE) is typically stateless and acts as a proxy for other services, including authentication, authorization, and core services. The recent divorce of browser code being rendered by backend services was created by SPAs - Single Page Applications. In simpler architectures, a SPA and service could be as simple as: