Skip to content

Empty parent directories are not preserved with --outDir #2644

Description

@alexeagle

I have a source structure in which there is a single top-level directory, and I expect the same structure to be produced in the outDir, instead it is dropped. It seems that tsc trims singleton parent directories.
That behavior is okay, but I would like to be able to explicitly say what the baseDir is, and have the output structure match the input, relative to the baseDir.

Here is a session which demonstrates the problem:

alexeagle-macbookpro2:tmp alexeagle$ mkdir -p dir1/dir2/dir3
alexeagle-macbookpro2:tmp alexeagle$ cat > dir1/dir2/dir3/test3.ts
console.log("dir3");
alexeagle-macbookpro2:tmp alexeagle$ mkdir out
alexeagle-macbookpro2:tmp alexeagle$ tsc --outDir out dir1/dir2/dir3/test3.ts
alexeagle-macbookpro2:tmp alexeagle$ ls out/
test3.js
alexeagle-macbookpro2:tmp alexeagle$ cat > dir1/dir2/test2.ts
console.log('dir2');
alexeagle-macbookpro2:tmp alexeagle$ tsc --outDir out dir1/dir2/dir3/test3.ts dir1/dir2/test2.ts
alexeagle-macbookpro2:tmp alexeagle$ ls out
dir3    test2.js

It's kind of surprising that by adding a file in dir2, the test3.js file has disappeared from the outDir.

Activity

  1. mhegazy commented on Apr 6, 2015

    @mhegazy
    Contributor

    This is something we need to add. The current behaviour is that the basePath/CommonSourceRoot/ProjectRoot is computed as the longest common directory of all source files. and that is what is used to replicate the input structure under the output directory..

    We have discussed this issue before in #2034 (comment) and in #287

  2. locked and limited conversation to collaborators on Jun 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions