Description
TypeScript Version: 2.1.1 / nightly (2.2.0-dev.201xxxxx)
Code
This is a compiler issue, I have created a git repo that quickly reproduces the issue - https://github.com/dmarginian/ag-grid-ng2-ts-issue.git. Please follow the README to reproduce the problem.
Expected behavior:
Consistent outDir behavior which is not impacted by 3rd party distributions. No compilation of 3rd party ts when a d.ts is present. This is consistent with the FAQ:
"To do so, the compiler needs the definition of a module, this could be a .ts file for your own code, or a .d.ts for an imported definition files."
This implies ts files are used for my code and .d.ts files are used for imported 3rd parties.
Related issues: #6964
Actual behavior:
When 3rd party dependencies include .ts files in their distribution the source directory is appended to outDir and all compiled js is under the source directory (e.g. outDir/src). If the .ts files are manually removed from the 3rd party the source directory is not appended to outDir. Please see angular/angular#13307 (comment) for the reasons why ag-grid-ng2 is including .ts files in their distribution.
If the rootDir flag is used an error occurs which indicates tsc is attempting to compile the 3rd party:
error TS6059: File '/home/david/dev/projects/ms-ng2-common-modules/ts-issue/node_modules/ag-grid-ng2/main.ts' is not under 'rootDir' '/home/david/dev/projects/ms-ng2-common-modules/ts-issue/src'. 'rootDir' is expected to contain all source files.