-
Notifications
You must be signed in to change notification settings - Fork 12
0007 proposal: to adapt Typescript in backend. #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # Adopt Typescript in our Backend | ||
|
|
||
| * Status: proposed | ||
| <!-- {proposed | rejected | accepted | deprecated | … | superseded by [ADR-0005](0005-example.md)} --> <!-- optional --> | ||
| * Deciders: ZavenArra Daniel Dadiorchen Nick Aron | ||
| <!-- Find deciders here: https://github.com/orgs/Greenstand/people --> | ||
| * Date: 2022-06-02 <!-- optional --> | ||
|
|
||
| Technical Story: {description | ticket/issue URL} <!-- optional --> | ||
|
|
||
| ## Context and Problem Statement | ||
|
|
||
| With the backend getting more and more complex, we need to adopt Typescript to make it easier to maintain, code and read. | ||
|
|
||
| ## Decision Drivers <!-- optional --> | ||
|
|
||
| * The complexity of the backend is growing, a weak type of language is becoming too hard to maintain the interface between: function, class, file. | ||
| * The code productivity. | ||
| * The code quality. | ||
|
|
||
| ## Considered Options | ||
|
|
||
| * Using Typescript in the backend. | ||
| * Using vanilla Javascript in the backend. | ||
|
|
||
| <!-- ## Decision Outcome | ||
|
|
||
| Chosen option: "{option 1}", because {justification. e.g., only option, which meets k.o. criterion decision driver | which resolves force {force} | … | comes out best (see below)}. | ||
|
|
||
| ### Positive Consequences | ||
|
|
||
| * {e.g., improvement of quality attribute satisfaction, follow-up decisions required, …} | ||
| * … | ||
|
|
||
| ### Negative Consequences | ||
|
|
||
| * {e.g., compromising quality attribute, follow-up decisions required, …} | ||
| * … --> | ||
|
|
||
| ## Pros and Cons of the Options <!-- optional --> | ||
|
|
||
| ### Using Typescript in the backend | ||
|
|
||
| {example | description | pointer to more information | …} <!-- optional --> | ||
|
|
||
| * Good, because of a better code maintainability. | ||
|
|
||
| With Typescript, we can navigate the code pretty much easier, to find definition of function/class/variables/files etc. If we use VSCode, we can check the definition by hovering the mouse over the variable, auto-completion when coding, auto-import when coding, auto-fix when warn/error detected. Basically, to jump between files is a big cumbersome using vanilla Javascript. | ||
|
|
||
| Currently, my feel is that over 60% of library (popular) is supporting Typescript, even a lib is not written in TS, the lib provider will define the TS interface for user. | ||
|
|
||
| With these supports, my experience is that with TS, the code productivity gains 10% higher than with vanilla Javascript, in a complicated logic business system. | ||
|
|
||
| The code in Typescript is more readable. | ||
|
|
||
| * Good, because it brings higher code quality. | ||
|
|
||
| With the TS type checking, we can make sure every invocation of the function/class is correct, this can help on development stage (by auto-fix), and also help on test and production stage, by denying committing or CI. Especially when the logic is complicated, and when we change the interface of the code when evolving or refactoring. | ||
|
|
||
| * Bad, poorer performance. | ||
|
|
||
| With TS, it's for sure, when coding, some feature like: auto-refresh would be slower. It also take extra time to compile the code. | ||
|
|
||
| For production env, we can run complied pure Javascript code instead. | ||
|
|
||
| * Bad, higher learning curve. | ||
|
|
||
| Developer need to learn Typescript. | ||
|
|
||
| But, I suggest we just use the most basic features of Typescript. Because a over-typed System goes to a wrong direction, actually it makes the code less readable. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest splitting this out into a separate option:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My knowledge of Typescript is basic, but any typed language gives good tools to model the domain, but modeling it right is an ongoing process regardless of the language.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @arunbakt that's a book to discuss it :D |
||
|
|
||
| So I suggest we just use TS in a simple way, and if we set up the codebase with Typescript correctly, then a newcoming developer shouldn't need to take a long time to learn Typescript to start coding. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with this. Basic TypeScript features can bring a lot of benefits.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, maybe a good eslint config, TS config and template repo is helpful |
||
|
|
||
| ### {option 2} | ||
|
|
||
| {example | description | pointer to more information | …} <!-- optional --> | ||
|
|
||
| * Good, because {argument a} | ||
| * Good, because {argument b} | ||
| * Bad, because {argument c} | ||
| * … <!-- numbers of pros and cons can vary --> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could consider compiled languages too like Kotlin, but I understand Typescript is a natural progression from javascript.