JS Proxies for array indices getters & setters
Reliable I/O with the TypeScript Compiler API (Video)
My New Book! The Typescript Compiler API
React Query Codegen from OpenAPI
Rapini is a new tool that can generate custom React Query hooks using OpenAPI (Swagger) files.
The Command Line Interface (CLI) tool will take a path to an Open API file and generate a package that includes react hooks, typescript types and axios http requests - and this package is conveniently bundled in a way that it can be published to NPM or any other package registry of your choosing.
No need to manually write axios request functions and react query code to start using your backend endpoints, just generate and import your code to ship features faster.
Simple Remote Data in Typescript
Introducing Simple Remote Data (SRD), a Static Land compliant TypeScript library for managing state from remote sources.
SRD’s top features are:
- Only 549 bytes minified and gzipped, that is ridiculously small!
- Built with Higher Kinded Types (HKT’s) to allow Typescript to infer these complex disjoint union types.
- Static Land compliant!
- Made for React or any other JS based frontend framework.
What is a Remote Data type?
A Remote Data type is a kind of discriminate union type in functional programming for managing the state of some data that is retrieved remotely and asynchronously, such as http response data, websockets, server sent events, reading a file, or any other async IO.
Using TypeScript ADT’s to write more reliable React
You may have heard of Algebraic Data Types (ADT’s) before but didn’t understand how they can be applied to everyday code - so this article will provide some examples and explanations of why you should start using them.
Before we get into ADT’s, let’s go over the foundation of what ADT’s are made of.
Basic Types
In Javascript, you can not declare a type that prevents other types from being assigned to it. The below example we see that anything can be assigned to the language variable. We can assign a number or a boolean or an object to it if we later wanted, but that may cause bugs in the future if we were not expecting the variable type to be something other than a string.