Setup typescript alias and barrels
Typescript alias are very useful to avoid importing modules like this
with alias we can import like this
How to add an alias
In tsconfig.ts
you can add ad many alias you need eg:
Barrels
Barrels are an handy way to export multiple modules from one module / file that will work like proxy eg:
you have some services:
app/services/service-one.service.ts
app/services/service-two.service.ts
instead of importing like this, specifing the exact filename and using multiple lines of code
we can define a barrel in eg app/services/index.ts
with this content
and then we can import (using the alias too) like this (a lot faster and clear)
Last updated
Was this helpful?