2024-05-31
1891
#react#typescript
Oghenetega Denedo
176070
109
May 31, 2024 â‹… 6 min read

Using path aliases for cleaner React and TypeScript imports

Oghenetega Denedo I'm a curiosity-driven software engineer with a focus on building reliable software that's easy to maintain and follows industry best practices.

Recent posts:

How To Use Lazy Initialization Pattern With Rust 1.80

How to use the lazy initialization pattern with Rust 1.80

Efficient initializing is crucial to smooth-running websites. One way to optimize that process is through lazy initialization in Rust 1.80.

Yashodhan Joshi
Nov 18, 2024 â‹… 5 min read
React logo on a bubbly orange background. Guide on building adaptive and responsive UIs in React Native for diverse devices.

Creating adaptive and responsive UIs in React Native

Design React Native UIs that look great on any device by using adaptive layouts, responsive scaling, and platform-specific tools.

Chinwike Maduabuchi
Nov 15, 2024 â‹… 9 min read
Enhancing Two-Way Data Binding In Angular

Enhancing two-way data binding in Angular

Angular’s two-way data binding has evolved with signals, offering improved performance, simpler syntax, and better type inference.

Alexander Godwin
Nov 14, 2024 â‹… 6 min read
Hand holding purple sticky notes for CSS sticky positioning guide.

Troubleshooting CSS sticky positioning

Fix sticky positioning issues in CSS, from missing offsets to overflow conflicts in flex, grid, and container height constraints.

Ibadehin Mojeed
Nov 13, 2024 â‹… 5 min read
View all posts

7 Replies to "Using path aliases for cleaner React and TypeScript imports"

  1. When importing files like this, how would you use it when using the import statement for lazy loading?

    React may not understand that path and would throw an error.

  2. This is a bad idea. If your imports are getting ugly, fix your code organization instead. This has performance impacts that are awful, and goes against the js standard which presents issues with all kinds of libraries and tooling. Research how module resolution works, it’s an expensive operation. Devs need to quit fighting standards and trying to turn js into Java etc…

    1. Hi Joshua, thanks for this feedback. We’ve added some more information in the “Best practices” section to emphasize the importance of following approved standards and organizing code properly rather than using path aliases as a quick fix. While it’s true that path aliases can sometimes impact performance — especially when not used wisely — we also added some clarifications around how TypeScript and build tools help counter potential performance issues. We appreciate your taking the time to read this article and share your thoughts!

    2. I agree, if you need path aliases to hide the fact that you have a poorly-designed project structure, you have a bigger problem on your hands.

Leave a Reply