-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Error messages use relative paths instead of absolute #7238
Comments
it is intentional. they are relative to the current directory the compiler was executed in. this make it much easier for command line scenarios when you run tsc in a folder, instead of all errors having full folder path, it becomes much more user friendly. |
We are running tsc from a custom build tool, which runs as a server watching the source directory for changes. So I guess for us it will be relative to whatever the working directory is for the build server, which is launched by another tool and runs in the background. The paths end up looking like But I can see that this scenario isn't common, and that the relative paths are friendlier when used directly from the command line on non-generated source files. |
I noticed another side-effect of this change is that Webstorm will not link the file in the terminal since it expects absolute paths for its output filter macro. |
+1 It would be nice to have a compiler option to print absolute file paths of input files with errors for backwards compatibility. This would involve adding a new compiler option and a dependant code branch in |
New compiler options add complexity both for usage and for maintenance. i would punt on this issue for now unless there are new scenarios. |
That's too bad, since it means we'll have to:
This will be a lot of finicky work that typescript could do much more easily. I do see the point about adding complexity in the compiler, just be aware that this shifts the complexity to some of your users. |
This is also the same problem when running a tsc build task from VS Code. It's similar to webstorm in that the relative paths do not become links whereas previously, full-paths did. I agree with @aychtang that this should be a compiler option for backwards compatibility for the large number of people who've built their tool chains around the previous functionality. |
I also get the point about compiler complexity, but this forces us to jump through hoops to do something that we've been able to do for years and years: double click on an error to jump to the source line. |
Please revisit this and add a "emit full paths" compiler option. My situation: In a VS project I call gulp (with gulp-typescript) in a post-build action. The problem is that gulp.task("build",
withChangedWorkingDir("dir/to/my/project", function () {
var tsProject = ts.createProject("tsconfig.json");
var tsResult = tsProject.src().pipe(ts(tsProject));
return tsResult.js.pipe(gulp.dest("."));
}));
function withChangedWorkingDir(path, callback) {
return function () {
var savedDir = process.cwd(path);
process.chdir(path);
try {
callback();
} finally {
process.chdir(savedDir);
}
};
} EDIT: The above workaround doesn't work when using a |
I think you'd have to change |
I need full file paths (enabled by a compiler option) in all error messages, like it happens for paths outside of the Regarding change in gulp-typescript: yes, possible + in all the other |
TypeScript Version:
1.8.2
Problem
I've found that somewhere between typescript 1.6.2 and 1.8.2, it started printing relative file names in error messages instead of absolute file names. This makes it harder for us to find the right (generated) input file, since we have to know what the paths are relative to. Was this change on purpose, or accidental? It's not listed in the change log.
The text was updated successfully, but these errors were encountered: