Skip to content

5.5.0 inheriting outDir: ${configDir} does not automatically exclude it from compilation #58327

Closed

Description

🔎 Search Terms

configDir

🕗 Version & Regression Information

This is likely bug with feature introduced in 5.5.0

⏯ Playground Link

https://github.com/Knagis/importHelpers-5.5.0/tree/exclude-lib

💻 Code

tsconfig.base.json

{
    "compilerOptions": {
        "outDir": "${configDir}/lib",
    },
}

packages/foo/tsconfig.json

{
    "extends": "../../tsconfig.base.json",
    "compilerOptions": {
        "composite": true,
        // "outDir": "lib" // uncomment to make it work
    },
    "include": [
        "**/*.ts"
    ],
}

🙁 Actual behavior

When using outDir: "${configDir}/lib" in the base config, compiling this project results in

error TS5055: Cannot write file 'C:/Code/tslibissue/packages/foo/lib/src/index.d.ts' because it would overwrite input file.

🙂 Expected behavior

Project compiles without errors

Additional information about the issue

If i specify outDir: "lib" or even outDir: "${configDir}/lib" in the derived config, the project compiles without errors as the lib folder seems to be automatically excluded from the compilation.

Activity

  1. Knagis commented on Apr 26, 2024

    @Knagis
    ContributorAuthor

    Updated/simplified reproduction repo, now it reproduces the stated error as is and uncommenting outDir in the derived tsconfig.json prevents it.

  2. Knagis commented on Apr 26, 2024

    @Knagis
    ContributorAuthor

    tsc --showConfig with inherited outDir:

    {
        "compilerOptions": {
            "outDir": "./lib",
            "composite": true,
            "declaration": true,
            "incremental": true
        },
        "files": [
            "./lib/src/index.d.ts",
            "./lib/src/index.spec.d.ts",
            "./src/index.spec.ts",
            "./src/index.ts"
        ],
        "include": [
            "**/*.ts"
        ]
    }

    the same with outDir defined in the derived config:

    {
        "compilerOptions": {
            "outDir": "./lib",
            "composite": true,
            "declaration": true,
            "incremental": true
        },
        "files": [
            "./src/index.spec.ts",
            "./src/index.ts"
        ],
        "include": [
            "**/*.ts"
        ],
        "exclude": [
            "lib"
        ]
    }
  3. Knagis commented on Apr 26, 2024

    @Knagis
    ContributorAuthor

    ok, so the issue isn't really configDir - but that the outDir from base config isn't ever applied as exclude rule. if i specify outDir: "packages/foo/lib" in the root, the same issue appears. Just that before ${configDir} it never made sense to not have outDir specified in the derived config file.

    for my added confusion, for some reason, with 5.5.0 it doesn't seem enough to specify outDir in the derived config anymore in my monorepo, i have to instead explicitly, manually add the folder to exclude list, which wasn't needed in 5.4.5. but maybe this is some cache playing a role, even though i build with -f

  4. added 2 commits that reference this issue on Apr 26, 2024
    40b76c3
    a00374d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions