tsconfig.json path pattern

1.8k Views Asked by At

Is there any way to include files by path pattern? For example, I am currently doing this in my scripts:

import '../../../../myresource/src/shared/my-interface'

However, I would like to simply use this:

import '@myresource/shared/my-interface'

Notice that in the last example, specifying the 'src' folder has been skipped. Also, 'myresource' would be changed to match any folder at that path ('myresource', 'myresource1', 'myresource2', etc..), so I would like to know if there's any solution which would not require me to add each specific folder inside the 'paths' object of the tsconfig.json

1

There are 1 best solutions below

0
On

You can do this in your tsconfig.json (example):

{
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": {
      "@*": ["*"]
    }
  }
}

You can also customize the paths for your needs.

{
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": {
      "@*": ["*", "dir1/*"]
    }
  }
}