Better Programming

Advice for programmers.

Follow publication

Member-only story

6 TypeScript Code Patterns To Make Your Code More Robust

Sunny Sun
Better Programming
Published in
5 min readOct 6, 2021

TypeScript Code Pattern
Photo by Vipul Jha on Unsplash

Use Pick To Implement Interface Segregation Principle

type ClientSummary = Exclude<Client, 'dateOfBirth'>;

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Sunny Sun
Sunny Sun

Written by Sunny Sun

I am full stack developer. Love coding, learning, writing. Checkout my NestJS course: https://shorturl.at/cpJM7, visit my blog https://coffeethinkcode.com

Responses (10)

Write a response

Nice idea!
I personally pass interface only when have 3+ params in a functions. but the idea is totally cool!

2

Thanks for sharing.

1

Unfortunately, `OpaqueType` does not work cleanly without type casting. For example, next code throw an error:
const cust: Customer = {name: 'John'};

3