tsconfig paths - resolve @dashboard to ./components/dashboard/index

Viewed 20

I have the following folder structure

./components/dashboard/index.tsx
./components/dashboard/users/usertable.tsx

I would like to have a tsconfig where I can do:

import dashboard from '@dashboard'
import usertable from '@dashboard/users/usertable

I can get the first behaviour by setting

"paths": {
      "@dashboard":["./components/dashboard"],
    }

and the second one by setting

"paths": {
      "@dashboard/*":["./components/dashboard/*"],
    }

How can I get them both at the same time though?

1 Answers

The solution was quite simple - setting both paths at the same time:

"paths": {
      "@dashboard":["./components/dashboard"],
      "@dashboard/*":["./components/dashboard/*"]
    }
Related