DEV Community

Discussion on: Top three React & TypeScript pitfalls

Collapse
devinrhode2 profile image
Devin Rhode

RE: "Is MyComponentProps type used somewhere else?"

In vscode, you can right click exported variables and select "Find all references"

Collapse
wojciechmatuszewski profile image
Wojciech Matuszewski Author

Thank you for reaching out.

The problem with your approach is that it's optimizing for a local maximum - your environment.

The goal of writing code should be to optimize for a global maximum - readability and precision in every situation and every circumstance. That is why I think it's essential to take a step back and not think about what my editor can do and communicate the intent with the way code is structured and written in a given file.

Exporting things in JavaScript makes it unclear (by just looking at the code) what kind of other parts of the codebase use that exported symbol.
This uncertainty can be dangerous, albeit mostly in extreme cases, but I believe it's still something we should watch out for.