typescript

Assertions: How to Assert Conditions and Types

The asserts statement was introduced in TypeScript 3.7. It’s a special type of function signature that tells the TypeScript compiler that a particular condition is true from that point on. Essentially, assertions serve as macros for if-then-error statements, allowing us to encapsulate precondition checks at the beginning of function blocks, enhancing the predictability and stability of our c... »

Soft Delete: Dealing With Unique Constraint in Real-World Case

ntroduced how to achieve soft delete in ZenStack in the previous post. The solution appears quite elegant with the help of the access policy in the schema. model Post { ... deleted Boolean @default(false) @omit @@deny(‘read’, deleted) ... } There are users who come to ZenStack specifically for the soft delete feature after reading the post: This was an “aha” moment in building ZenStack for me to b... »

LLMs for Schema Augmentation

I have recently been experimenting with the use of large language models (LLMs) to augment JSON Schemas with useful features. While ChatGPT gets most of the press, there are many other LLMs that are specifically designed to work with code. The idea is that these LLMs can be used to augment incomplete schemas with additional useful information. Consider an example schema such as the one below. This... »

Understanding TypeScript Types: Primitives, Objects, and Type Manipulations

TypeScript Types TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. TypeScript types are categorized into primitive types and object types. The basic types in TypeScript include string, boolean, number, array, tuple, and enum. TypeScript’s type system allows you to build new types out of existing ones using a large variety o... »

A Comprehensive Guide to TypeScript: Introduction, Installation, and Running Code

What is TypeScript? TypeScript is an object-oriented programming language created and maintained by Microsoft Corporation. It is a free and open-source high-level programming language that adds static typing with optional type annotations to JavaScript. TypeScript is a strict superset of ECMAScript 2015, commonly referred to as JavaScript. Being a “Syntactic Superset,” TypeScript share... »