Skip to content

Commit dab939a

Browse files
committed
docs: ADR for Typescript Guidance
1 parent c459497 commit dab939a

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

docs/0003-typescript-guidance.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Introducing TypeScript
2+
3+
## Status
4+
Accepted
5+
6+
## Context
7+
TypeScript is a strongly-typed superset of JavaScript that adds optional static type checking, class-based object-oriented programming, and other features to JavaScript.
8+
Here are some of the advantages of TypeScript over JavaScript:
9+
10+
### Type safety
11+
TypeScript helps catch errors at compile-time instead of runtime by adding type annotations to variables, functions, and classes. This can help prevent errors that might occur when dealing with large codebases.
12+
### Better tooling support
13+
TypeScript has better tooling support than JavaScript, with features like code navigation, auto-completion, and refactoring tools in popular code editors like Visual Studio Code.
14+
### Improved code organization
15+
TypeScript's class-based object-oriented programming model allows developers to organize code in a more structured and maintainable way.
16+
### Easy adoption
17+
TypeScript is a superset of JavaScript, which means that any valid JavaScript code is also valid TypeScript code. This makes it easy for developers to adopt TypeScript gradually, without needing to rewrite their entire codebase.
18+
### Community support
19+
TypeScript has a growing community of developers who contribute to its development, create libraries and tools, and provide support to other developers. This makes it easier for developers to learn and adopt TypeScript.
20+
21+
## Decision
22+
### Target Goals
23+
Prioritize using TypeScript in the following places:
24+
* New code files
25+
* Existing API endpoints (and their payloads)
26+
* Components or Functions take a lot of parameters, or use parameters that are themselves complex objects
27+
28+
Less important are:
29+
* React components without complex input objects (especially since they are often adequately served with PropTypes)
30+
* Test code
31+
32+
### Migration Strategy
33+
While migrating Javascript code to TypeScript code is relatively straightforward, the initial introduction of TypeScript into a code base can involve some unexpected wrinkles. While we will
34+
work to streamline our infrastructure to make this easier over time, we advise introducing TypeScript in a minimalist fashion initially, by introducing or migrating a single file into TypeScript (or even a single function within a file).
35+
36+
The reasons for this are practical:
37+
* The most difficult part of the initial process of introducing TypeScript into a Javascript codebase is harmonizing with the existing build, test, and lint configuration.
38+
* The smaller the initial effort of introducing TypeScript into a codebase, the easier it is to actually implement around more pressing feature work.
39+
40+
## Consequences
41+
### Benefits
42+
* Code that requires heavy contracts, whether that's functions/components with lots or parameters, or complex objects returned from backend API's, will become much more comprehensible and easier to work with in a modern programming IDE.
43+
* Because TypeScript is a superset of Javascript, the code does not need to be migrated all at once, but can be updated to TypeScript during the course of regular feature work.
44+
45+
### Challenges
46+
* Migrating to TypeScript falls into the category of Tech Debt, which is difficult to get around to around the demands of mission-critical feature work and bug fixes.
47+
* There can be a bit of a learning curve around using TypeScript, particularly for Javascript developers who don't have prior experience with strongly-typed languages.
48+
49+
## References
50+
* https://www.typescriptlang.org/

0 commit comments

Comments
 (0)