Skip to content

Multiple source roots - or something like classpath, like python_path, like include_path !!! #5893

Closed
@iongion

Description

@iongion

I need to have the following structure:

  • build
    • debug
    • release
  • sources
    • clients
      • APIClient.ts
    • runtime
    • services
  • test
    • cases
      • clients
        • APIClientTest.ts
      • runtime
      • services
  • typings

My goal is that in the tests I want to be able to import the associated tested class without using /// reference.

This would work out of the box if the test would stay right next to the class, not in separate directories:

  • build
    • debug
    • release
  • sources
    • clients
      • APIClient.ts
      • APIClientTest.ts
    • runtime
    • services
  • typings

But it is extremly ugly and dirty and it gets even more so when these folders start growing(hundreds of classes, hundreds of tests ...)

My second attempt was to use a tsconfig.json:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "noImplicitAny": true,
        "noEmitOnError": true,
        "outDir": "./build/debug",
        "rootDir": "./",
        "sourceMap": false
    },
    "exclude": [
        "build",
        "node_modules"
    ]
}

But this creates weird folder structure inside build, understandable because it considers project root as source root which is not the same thing at all. Now, from what I've tried, the ideal situation would be to have multiple source directories that output in the same build dir. In this way, the tests would be able to avoid having to declare the horor that is /// reference.

I could use different tsconfig.json for sources and test directories, but then how do you specify the tests that references can be found additionally in another directory too.

What do you recommend, what can be done ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions