Skip to content

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

Closed
@alexeagle

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.

Metadata

Metadata

Assignees

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