How to specify multiple source folders in tsconfig.json?

I currently have the following project structure:

project/
  tsconfig.json
  webpack.config.js
  package.json
  node_modules/
    ...lots of dependencies
  typings/
    ...lots of .d.ts files for the dependencies
  src/
    ...folders for files for my projects

My tsonfig.jsonlooks like this:

{
"compilerOptions": {
    "module": "commonjs",
    "target": "es5",
    "noImplicitAny": false,
    "outDir": "./js",
    "rootDir": "./src",
    "sourceMap": true,
    "jsx": "react"
},
"exclude": [
    "typings/main.d.ts",
    "typings/main",
    "node_modules"
    ]
}

All this works very well, and I can happily develop the application and run it in a browser.

Now I would like to add some unit tests to my project and, based on the Java background, my initial instinct is to place the tests in a separate folder:

project/
  test/
    ...all of my test cases

Of course, the files in the folder test/should reference the code in my folder src/. How to set it up?

Or is it better to place inline tests in a folder src/and have a separate file for them webpack.config.js?

Really confused about how this works in practice in larger TypeScript projects.

. , . , filesGlob , , ?

+4
2

"" inline src/ webpack.config.js?

. TypeScript ( https://github.com/TypeStrong/atom-typescript/blob/master/docs/out.md). webpack ( commonjs) (nodejs).

+1

, . paths , . :

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

, "" . baseUrl , .

+1

All Articles