An open API service indexing awesome lists of open source software.

https://github.com/mildronize/type-safe-design-pattern

Type-safe Design Pattern in Modern TypeScript
https://github.com/mildronize/type-safe-design-pattern

Last synced: 12 months ago
JSON representation

Type-safe Design Pattern in Modern TypeScript

Awesome Lists containing this project

README

          

# Type-safe Design Pattern in Modern TypeScript

This book provide ready to use design pattern for type-safe approach in modern typescript
by Thada Wangthammang

## Table of Contents

- TypeScript Config
- Use strict
- Data Structure
- Use literal type rathen than string
- Use Record object rather than list/array
- Use Tuple rather than list/array
- Design Patterns
- Use builder pattern
- Use function argument instead of plain object
- Use function overload

## Prerequisites
Please make sure you have a good understanding of TypeScript before reading this book. If you are new to TypeScript, I recommend reading the [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/intro.html) first.

Generics are a fundamental concept in TypeScript, so make sure you understand them. You can read the [Generics](https://www.typescriptlang.org/docs/handbook/2/generics.html) section of the TypeScript Handbook.

After that, make sure you have understand type-level programming. You can read the [Type-Level Programming](https://type-level-typescript.com/) book.
There are many free chapters available. However, I recommend buying the book to support the author.

## Disclaimer

I did not create these design patterns. I learned from various modern TypeScript open-source projects, including famous ones like Zod, tRPC, Hono, Elysia, and many others, as well as writing the [Nammtham](https://nammatham.thaitype.dev/) (Azure Functions Framework). This process has helped me distill commonly used patterns.

The type-safe design patterns is not suitable for every project. It is intended for projects that require high code quality and design. Make sure to evaluate whether these patterns are suitable for your project before using them.

## Contributing
If you have any suggestions or feedback, please feel free to open an issue or submit a pull request on [GitHub](https://github.com/mildronize/type-safe-design-pattern)

## License
This book is licensed under the [CC BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/)