-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe57c2c
commit 6004433
Showing
3 changed files
with
41 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License | ||
|
||
This work by Thada Wangthammang, @2024 is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. | ||
You may copy and redistribute the material in any medium or format for non-commercial purposes only, provided proper attribution is given, but you may not distribute any modified material. | ||
For details, see the full license at https://creativecommons.org/licenses/by-nc-nd/4.0/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,37 @@ | ||
# book-type-safe-design-pattern | ||
# Type-safe Design Pattern in Modern TypeScript | ||
|
||
To install dependencies: | ||
This book provide ready to use design pattern for type-safe approach in modern typescript | ||
by Thada Wangthammang | ||
|
||
```bash | ||
bun install | ||
``` | ||
## Table of Contents | ||
|
||
To run: | ||
- 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 | ||
|
||
```bash | ||
bun run index.ts | ||
``` | ||
## 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. | ||
|
||
This project was created using `bun init` in bun v1.1.7. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. | ||
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/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters