Using TypeScript with Node.js

TypeScript adds to programmer productivity and expressiveness, and is not dying

(Thu Sep 21 2023 00:00:00 GMT+0300 (Eastern European Summer Time)) Recently the teams for a couple front-end libraries abandoned using TypeScript and returned to vanilla JavaScript. That leads some to claim TypeScript is dying, and anyway that it doesn't provide useful productivity advantages to developers. While I do not have data on software development trends, I do find TypeScript adds significantly to my development work, without costing significant time.

Automatically handling runtime data validation in TypeScript

(Fri May 27 2022 00:00:00 GMT+0300 (Eastern European Summer Time)) TypeScript does excellent compile time type checking. But that does not mean TypeScript code ensures runtime type or data validation or checking. TypeScript compiles code to JavaScript with no runtime checking, leaving the door open to runtime data problems.

Generating API documentation for TypeScript packages with TypeDoc

(Sat Mar 12 2022 00:00:00 GMT+0200 (Eastern European Standard Time)) With TypeDoc, one adds structured comments (JSDoc style comments) to TypeScript source code. With data in those comments, TypeDoc generates nice API documentation you can easily publish to a website. With the addition of another tool, gh-pages, it is easy to publish the documentation to GitHub Pages.

Using automated runtime data validation decorators in TypeScript

(Thu Mar 10 2022 00:00:00 GMT+0200 (Eastern European Standard Time)) A new package for TypeScript enables us to automatically check validity of runtime data, without having to explicitly call a validation library. Instead, the runtime-data-validation package lets us attach decorators describing data validity, and arranges for validation to be automatically performed on assigning a value to a property, or when calling a method.

Deep introduction to parameter decorators in TypeScript

(Tue Feb 22 2022 00:00:00 GMT+0200 (Eastern European Standard Time)) Decorators allow us to add additional information to classes or methods in TypeScript, and are similar to annotations such as in Java. Parameter decorators are applied to method parameter definitions in TypeScript. With them, we can record information about parameters, including customized information, using that data in other features.

Runtime data validation in TypeScript using decorators and reflection metadata

(Tue Feb 22 2022 00:00:00 GMT+0200 (Eastern European Standard Time)) TypeScript decorators allowed us to intercept calls to both accessor functions and methods. That let us spy on data passed to either type of function, or even to supply default values for any that are missing. A practical use we might have for this is automatic validation of data arriving at an accessor or method. By instrumenting these functions, a validation package can act as a gatekeeper ensuring that data in objects is always correct.

Implementing hybrid decorator functions in TypeScript

(Sun Feb 20 2022 00:00:00 GMT+0200 (Eastern European Standard Time)) The documentation on TypeScript decorators describes function signatures for each decorator type. It implies that each decorator must be implemented for a specific target object type. But, with a carefully defined method signature we can construct decorators to handle decorating any object type.

Using the Reflection and Reflection Metadata APIs with TypeScript Decorators

(Sun Feb 20 2022 00:00:00 GMT+0200 (Eastern European Standard Time)) Making full use of TypeScript decorators requires understanding the Reflection and Reflection Metadata API's. The latter lets you store data in object metadata so that decorators can work together to create complex behaviors.

Deep introduction to method decorators in TypeScript

(Thu Feb 17 2022 00:00:00 GMT+0200 (Eastern European Standard Time)) Decorators allow us to add additional information to classes or methods in TypeScript, and are similar to annotations such as in Java. Method decorators are applied to methods defined in classes in TypeScript. With them we can record information about methods, or modify method execution.

Deep introduction to accessor decorators in TypeScript

(Tue Feb 15 2022 00:00:00 GMT+0200 (Eastern European Standard Time)) Decorators allow us to add additional information to classes or methods in TypeScript, and are similar to annotations such as in Java. Accessor decorators are applied to accessor method definitions in TypeScript, and can observe, or modify data accessed through get/set functions. With care, they can be used for advanced features like runtime data validation.

Deep introduction to property decorators in TypeScript

(Sat Feb 12 2022 00:00:00 GMT+0200 (Eastern European Standard Time)) Decorators allow us to add additional information to classes or methods in TypeScript, and are similar to annotations such as in Java. Property decorators are applied to property definitions in TypeScript, and can observe them.

Deep introduction to class decorators in TypeScript

(Thu Feb 10 2022 00:00:00 GMT+0200 (Eastern European Standard Time)) Decorators allow us to add additional information to classes or methods in TypeScript, and are similar to annotations such as in Java. Class decorators are applied to class definitions in TypeScript, and can observe, modify, or replace the class definition.

Deep introduction to using and implementing TypeScript decorators

(Thu Feb 10 2022 00:00:00 GMT+0200 (Eastern European Standard Time)) Decorators allow us to add additional information to classes or methods in TypeScript. They're similar to annotations such as in Java. With decorators we can add a wide variety of functionality, with a very succinct notation. It is planned that decorators will become a standard part of JavaScript, making it important to learn how they work.

Data validation decorators in TypeScript

(Thu Feb 03 2022 00:00:00 GMT+0200 (Eastern European Standard Time)) Decorators are an interesting feature of TypeScript, which may become a standard part of JavaScript. They resemble annotations in other languages, in that they're attached to the declaration of something and add behavior or information to that thing. To get some familiarity, let us use a library of data validation decorators along with TypeORM.

Creating either CommonJS or ES6 modules for Node.js packages using Typescript

(Wed Feb 02 2022 00:00:00 GMT+0200 (Eastern European Standard Time)) The core unit of software on Node.js is the package. Therefore using TypeScript for Node.js applications requires learning how to create packages written in TypeScript or sometimes a hybrid of JavaScript and TypeScript. Fortunately this is easy for any Node.js programmer, and amounts to setting up the TypeScript compiler.

Setting up the Typescript compiler to integrate with Node.js development

(Sun Jan 30 2022 00:00:00 GMT+0200 (Eastern European Standard Time)) TypeScript is growing rapidly in popularity within the JavaScript ecosystem. TypeScript offers us important compile-time data type enforcement, for what is otherwise JavaScript code. Any large project written in JavaScript will, in theory, find this useful because, in theory, the larger the project the more likely the coders will have keeping track of data types. The TypeScript tools run on Node.js, and while it can generate code for Node.js, it can be configured for any JavaScript environment.

Complete guide to using TypeORM and TypeScript for data persistence in Node.js module

(Tue Jul 16 2019 00:00:00 GMT+0300 (Eastern European Summer Time)) TypeORM is an advanced object-relations-management module that runs in Node.js. As the name implies, TypeORM is meant to be used with TypeScript. In this article we'll learn about using TypeORM to set up Entity objects to store data in a database, how to use a CustomRepository instance to manipulate a database table, and to use Relations between Entity instances to simulate database joins.