cctv

Type Safety and Runtime Safety Part.1/2: model, validator & data

TypeScript makes JavaScript even stronger with a strongly-typed system, which is a merit for developers. TypeScript checks our static code before running it. That is so called type safety. However, runtime safety is checking our code at runtime with real data. In runtime, TypeScript files are already compiled to JavaScript. So static type check is not available. It means: type safe does not mean runtime safe The post is divided into two parts....

Mar 17, 2024 Published · Oct 3, 2024 Updated · 5 min · Inori Inuyama
cctv

Type Safety and Runtime Safety Part.2/2: page, route guard & API

The post is divided into two parts. If you want to read part 1 first, please go to here. As part 1 is about runtime validation. Part 2 will focus on use cases. I will use Nuxt3 as example. Here I have 3 use cases: page, route guard (Vue route) and API. Prerequisite Basic knowledge: JavaScript, TypeScript, Nuxt3, Vue3, zod Case 1: Page Validation Suppose we have a post list page with route: /posts?...

Mar 17, 2024 Published · Oct 3, 2024 Updated · 7 min · Inori Inuyama