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:

Rxjs Adoption Guide: Overview, Examples, And Alternatives

RxJS adoption guide: Overview, examples, and alternatives

Get to know RxJS features, benefits, and more to help you understand what it is, how it works, and why you should use it.

Emmanuel Odioko
Jul 26, 2024 â‹… 13 min read
Decoupling Monoliths Into Microservices With Feature Flags

Decoupling monoliths into microservices with feature flags

Explore how to effectively break down a monolithic application into microservices using feature flags and Flagsmith.

Kayode Adeniyi
Jul 25, 2024 â‹… 10 min read
Lots of multi-colored blue and purplish rectangles.

Animating dialog and popover elements with CSS @starting-style

Native dialog and popover elements have their own well-defined roles in modern-day frontend web development. Dialog elements are known to […]

Rahul Chhodde
Jul 24, 2024 â‹… 10 min read
Using Llama Index To Add Personal Data To Large Language Models

Using LlamaIndex to add personal data to LLMs

LlamaIndex provides tools for ingesting, processing, and implementing complex query workflows that combine data access with LLM prompting.

Ukeje Goodness
Jul 23, 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