How to Write Clean TypeScript Code

8 knowledge points to write elegant TypeScript code.

York Harrison
Better Programming
Published in
5 min readMar 19, 2022

--

How to Write Clean TypeScript Code | Tomoe Li
Photo by Olia Gozha on Unsplash

1. Mark with immutable types

There are constants that we don’t want to be modified in any way, and while the const keyword is nice, it doesn’t restrict the reference type and its value can still be modified, for example:

const obj = {
elementId…

--

--