🏁
Best Practices
  • Introduction
  • The Big Picture
    • Principles
      • Software engineers solve business problems
      • Programming is a social activity
      • Attention is the most precious resource in a project
      • Simplicity is the best ally in the long run
      • The only problem to solve is the one we have today
    • Architecture
      • Domain
      • Services
      • Persistence
      • HTTP
      • UI
    • Naming
  • Constraints
    • TypeScript
    • Monorepo
    • Monolith
    • Versioning
  • Source code
    • Declarative programming
    • The README
    • Modules
    • Folder structure
    • Code formatting
    • Code comments
  • The Outside World
    • Runtime configuration
    • Logging
  • Testing
    • The purpose of testing
      • End-to-end tests
      • Integration tests
      • Unit tests
  • Tools
    • Git
  • Resources
    • Resources
Powered by GitBook
On this page

Was this helpful?

  1. Constraints

TypeScript

PreviousNamingNextMonorepo

Last updated 5 years ago

Was this helpful?

My opinion is that every non-trivial project should use TypeScript instead of JavaScript nowadays, it should be considered the baseline.

The main reasons I'd highlight:

  • TypeScript allows code to be self-documenting to a high degree: interfaces, arguments, data shapes are typed and hence present an explicit contract

  • It will enable the codebase to scale since the data flow is validated end-to-end.

  • Provides a significant level of confidence about code correctness in itself

  • Prevents people from making mistakes in API usage - these can be very hard to catch without a type system

  • Catches common errors that could easily slip into production otherwise

  • Enables confident refactoring

  • Obsoletes a considerable number of unit tests that would be written just to verify argument handling

  • Provides typing for the standard JS/Node library

  • Comes with superb IDE support

Honestly, it feels reckless to refuse such a good deal.

Use TS in strict mode. Otherwise, there's always an excuse to skip typing.

Only use any in exceptional cases.

Type safety only works in our codebase. Validating runtime data is the responsibility of . If there is end-to-end type-safety, also plays a part.

the services
the Graph