Avoid centralizing TypeScript types


Avoid centralizing TypeScript types.

Why:
🚫 Creates ownership ambiguity
🚫 Makes it less clear what the type is for
🚫 Makes it unclear when we can safely change it

Instead:
1. Colocate types with their “source” (the spot that determines their shape)

2. Export when necessary
Examples:

✅ Declare REST API response type in the file that fetches.

✅ Declare a React prop type in the React component.

✅ Declare a type for a function signature in the same file as the function.

Rule:
Colocate types if you can. Centralize if you must.

View original on X