Skip to content

Directory appended to outDir if 3rd party dependencies include .ts files #13240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dmarginian opened this issue Jan 1, 2017 · 2 comments
Closed

Comments

@dmarginian
Copy link

dmarginian commented Jan 1, 2017

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.

@aluanhaddad
Copy link
Contributor

Works perfectly when running

tsc -p .\src\tsconfig.json

from the command line

Fails when using npm run tsc where tsc is the name of the "script" with the text tsc -p .\src\tsconfig.json pointing to the above command.

@dmarginian
Copy link
Author

Thanks for taking a look @aluanhaddad. This is because I have the TypeScript version pegged to 2.0.x. I modified it to 2.1.x and all is well. Sorry that I didn't catch this and thank you for your time.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants