'Exclude certain paths from being autoimported with Lerna, Typescript, and VS Code

I have a [email protected] project with a chain of multiple packages.

|-tsconfig.lib.json
|-packages
  |--format
  |----tsconfig.lib.json
  |--helper
  |----tsconfig.lib.json

Each package extends the tsconfig.lib.json from the top level. helper depends on format. When I go to auto import from format, I get three levels of imports:

  • packages/helper
  • @org-name/helper (the right one)
  • packages/helper/dist

How do I exclude the two import paths with packages without breaking all imports?



Solution 1:[1]

Years later, I think that https://www.typescriptlang.org/docs/handbook/project-references.html are the way to handle this with Typescript, at least.

Each tsconfig within packages would have a

   // packages/helper/tsconfig.lib.json
   "references": [
        { "path": "../format" }
    ]

The root package.json would include

"paths": {
   "@org-name/helper": "./packages/helper"
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1