Member-only story

TypeScript is Cumbersome and I Don’t Want to Use It!

DAOZHUO CHEN
6 min readMay 21, 2024

Preface

Recently, when our department was working on a component library, I noticed that some team members expressed resistance to using TypeScript, often complaining, “TypeScript is too cumbersome, we don’t want to use it!”At first, I was confused by this: Is TypeScript really that troublesome? However, when I took the time to review the team’s code, I finally figured out what the problem was. In this article, I would like to share with you some of my findings and solutions

Photo by Arian Darvishi on Unsplash

1. The type reuse is insufficient

During the code review process, I found a lot of duplicate type definitions, which significantly reduced the reusability of the code.

After further conversation, I learned that many team members were not clear about how to reuse types in TypeScript. TypeScript allows us to define types using type and interface.

When I asked them about the difference between type and interface, most of them said they didn’t know, so it’s no wonder they didn’t know how to reuse types effectively.

Types defined by type can be reused by intersecting types (&), while types defined by interface can be reused by inheritance (extends). It’s important to note that types defined by type and interface can also be reused with each…

--

--

DAOZHUO CHEN
DAOZHUO CHEN

Written by DAOZHUO CHEN

Java Development Engineer/Full Stack Engineer/Writer/Trying To Reach 1000 Followers / We Can Follow Each Other On Medium/Share Articles In Various Fields

No responses yet