Typescript Practices
This is opinionated documentation giving introduction into typescriptlanguage and beyond.
Idea of its creation is to give fast onboarding and knowledge refresh for the commonly used approaches and practices in day-to-day work.
Typescript Introduction
| Includes | |
|---|---|
| Typescript Introduction | Typescript, tsc, tsconfig.json, programmatic use |
| Project structure and package tools | npm, yarn, package.json, DefinitelyTyped |
| Linting And Formatting | eslint, prettier, @typescript-eslint |
Typescript Language
| Includes | |
|---|---|
| Variables* | let, const, scoping |
| Basic types* | common types |
| Type & interface * | definition, recursive, combining |
| Destructuring and spread* | for: tuples, array, objects |
| Function * | type definitions for regular, async , curried functions. this capturing |
| Modules | import, export, default export |
| Callbacks * | usage, maintenance complexity |
| Promise * | chaining, error handling, parallel processing |
| async/await * | async definitions, error handling |
| Classes * | members definitions |
| Iterate Array/Object * | for..of, for..in, Object alternatives |
Advanced topics
| Includes | |
|---|---|
| Generics * | function, type, interface |
| Utility Types* | Partial, Required, Record, Pick, Omit etc |
| Node.js | Node.js modules and globals |
| TSDocs | source code documentation |
| Async arrays * | async functions in map, reduce, etc |
| Custom Errors * | Error, extend Error, catch |
Practical Concepts
| Includes | |
|---|---|
| Class replacement * | use builder function instead of class definition |
| Union type instead of enum * | explanation when it is better to use union types instead of enum |
| Useful libraries | walk thru some commonly used libraries |
| jest | writing tests, configuration, mocks, expectations, jest-dynamodb |
| AWS Lambda | @types/aws-lambda, env, caching, DI, aws-sdk faking for tests |
Notes
Generated pages index:
* pages are fully generated from code, and could be examined in your favorite editor as one typescript file. Check them here
Some code samples include code playground links (bottom right) to https://www.typescriptlang.org/play so you could test it without leaving browser