Skip to main content

Command Palette

Search for a command to run...

TypeScript Won’t Save Your Product: The Case for Clean Code Practices

Why relying solely on TypeScript isn’t enough and how clean code principles make all the difference

Updated
2 min read
TypeScript Won’t Save Your Product: The Case for Clean Code Practices

You think using TypeScript is gonna keep your product alive, definitely NOT 😂 Here's why!

People are obsessed with TypeScript, and I don't say it's wrong.

But when it's used incorrectly (without proper clean code principles), even it'll cause a disaster instead of saving us.

Let me give you an example:

The Problem

const getLogs = (
  userId: string,
  from?: Date,
  to?: Date,
  sort?: Map<string, number>,
  limit?: number,
  lastLogId?: string
) => {};

This function might look fine at first glance, but it's not.

Now think about the consumer:

How will they know the order of all those optional parameters?

Having this many parameters in a function not only makes it harder to maintain but also makes it prone to errors.

The Solution

Here's a cleaner approach:

interface LogsOptions {
  interval?: {
    from?: Date;
    to?: Date;
  };
  pagination?: {
    limit?: number;
    lastLogId?: string;
  };
  sort?: Map<string, number>;
}

const getLogs = (userId: string, options?: LogsOptions) => {};

This approach is:
✅ Cleaner
✅ Easier to maintain
✅ Less prone to errors

Consumers can immediately understand what parameters are available without guessing.

Moral of the story

TypeScript alone won't save your product. Regardless of the language or framework you use, clean code principles play a vital role in your product's longevity.

Frameworks and languages come and go, but the fundamentals stay the same.

💬 What practices do you follow to keep your product alive? Share your thoughts in the comments!

Cheers,
Navayuvan Subramanian