title: Understanding "baseUrl" and "paths" in TypeScript with * glob
body: <p>I have a monorepo created with yarn workspaces and the following folder structure:</p>
  
  <pre><code>├── foo                   (workspace @project/foo)
  │   ├── package.json
  │   └── src
  │       └── index.ts
  ├── bar                   (workspace @project/bar)
  │   ├── package.json
  │   └── src
  │       └── index.ts
  ├── package.json          (monorepo root)
  └── tsconfig.json         (base tsconfig)
  </code></pre>
  
  <p>And the following settings in <code>tsconfig.json</code>:</p>
  
  <pre><code>{
    "compilerOptions": {
      "baseUrl": ".",
      "module": "commonjs",
      "paths": {
        "@project/foo/*": "./packages/foo/src/*",
        "@project/bar/*": "./packages/bar/src/*"
      },
      ...
    }
  }
  </code></pre>
  
  <p>In the <code>@project/bar</code> workspace, I want to import modules from <code>@project/foo</code>:</p>
  
  <pre><code>import foo from "@project/foo";
  </code></pre>
  
  <p>But I'm getting the following error:</p>
  
  <blockquote>
    <p>Cannot find module '@project/foo' or its corresponding type declarations.ts(2307)</p>
  </blockquote>
  
  <p>If I remove the <code>*</code> symbols from both the keys and the values of the "paths" object, the code compiles. Why is that? How can I keep the <code>*</code> glob pattern and make non-relative imports to my local modules?</p>