Visual Studio -> Shared TypeScript Library -> TS6059 File '' is not under 'rootDir' ''. 'rootDir' is expected to contain all source files

Ogglas picture Ogglas · Jan 10, 2018 · Viewed 12k times · Source

We are using Visual Studio 2017 and have two separate web projects that are supposed to share some React components written in TypeScript. There can also be shared JavaScript files and CSS files. For this we have created a Shared Project in Visual Studio.

What is the difference between a Shared Project and a Class Library in Visual Studio 2015?

Right now the project only has a single file with this information.

export const Types = {
    Type1: '1',
    Type2: '2',
    Type3: '3'
}

For testing I can reference it like this and Visual Studio will locate the file:

import { Types} from '../../../2/Constants/Types'

However when I then try to run webpack I get the following error:

TS6059: File '/2/Constants/Types.ts' is not under 'rootDir' '/1'. 'rootDir' is expected to contain all source files.

Answer

jedmao picture jedmao · Sep 16, 2018

I used the rootDirs compiler option for this purpose and it seems to work swell!

"rootDirs": [
  "../some/folder/outside",
  "src",
]