-
Notifications
You must be signed in to change notification settings - Fork 123
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
resolve paths relative to tsconfig.json #421
Comments
Thanks for the report. The feature is intended to allow tsconfig files to work within IDEs and with tsc -p, as you said. If you’re not seeing that, then there is a bug. It’s possible I didn’t implement the transform for rootDir correctly. I recommend that you use tsconfig passThrough true unless you want the overriding functionality of grunt-ts. I will investigate rootDir. |
I'm having this same issue - the output directory structure generated by grunt-ts is inconsistent with that generated by the IDE (WebStorm) and by running tsc directly against the same tsconfig.json that I feed to grunt-ts. |
As a workaround, I opted to call tsc directly using "grunt-exec": "3.0.0" as shown below. To be sure, this creates some difficulties when working cross-platform but the direct use of only tsconfig.json is appealing.
An important complication is the determination of the node path to use (cf. "./target/node/node") since this may differ from the system installation. We use the above on Linux and Windows. |
@MatthiasHild Thanks! I started going that route but then decided to use the tsconfig.grunt.json workaround as it was simpler and to not lose the nice console output that grunt-ts provides. |
I do not want to detract from the benefits of using a dedicated tsc wrapper! FYI, base output from exec as below. Additional output via tsconfig.json properties:
Sample output:
|
@MatthiasHild Ah ok, great! I missed those settings in tsconfig.json. Thanks again. |
Relative paths in tsconfig.json (such as rootDir) are resolved relative to Gruntfile.js instead of tsconfig.json.
As mentioned in issue #397, this causes problems when tsconfig.json is used by other tools, such as an IDE. There are more comments in pull #399.
I am afraid to say that I could not follow the reasoning in either thread and apologize if this is repetitious. I will offer two reasons to think that the current behaviour is a bug and not a feature.
First, the Typescript documentation seems not to be explicit on resolution of relative paths (what am I missing?) except when it discusses inheritance:
However, tsc implements resolution relative to tsconfig.json. It would seem to me that grunt-ts should compile tsconfig.json correctly iff
tsc -p path/to/ tsconfig.json
does (when tsc is called from the parent directory of the Gruntfile). This is currently not the case.Second, the following possible work-around is cumbersome:
For example, let:
tsconfig.json:
tsconfig.json would compile correctly for use by IDE or
tsc -p subdir/tsconfig.json
where tsc is called from the project directory projectdir/.tsconfig.grunt.json:
tsconfig.grunt.json is referenced in grunt-ts via
tsconfig: 'subdir/tsconfig.grunt.json'
.Many thanks for your great work!
The text was updated successfully, but these errors were encountered: