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
fix(compiler-cli): Return original sourceFile instead of redirected sourceFile #26036
Conversation
42f8e6e
to
800b878
Compare
Build seems to be failing because:
|
800b878
to
ded09d3
Compare
I confirm that it fixes watch on server. Is there a chance it get merged and released on an angular patch soon? |
Is this just going to be ignored forever? |
Please note that this needs to be fixed in for IVY as well: |
@JonWallsten sorry for the delay on this. It should start moving forward now. Would it be possible to post a PR with the Ivy fix as well? |
@Splaktar Sure! I'll get one done by this weekend. |
ded09d3
to
8b972a8
Compare
@Splaktar: I've updated the PR now. However, I don't know if there are more places. These are the two I've come across in my current project while bulding with Webpack. I did dig around some in the project but couldn't find any obvious ones. But then again. It's not crystal clear code-wise where this is an issue. There are around 40 places where getSourceFiles is used, but not all of them uses the source files. |
8b972a8
to
d111b23
Compare
@JoostK: Is it possible to trigger tests again without a new commit? |
@JonWallsten - hi Jon. Members of the angular org can retrigger CircleCI tests (possibly the PR author themselves can) by going to the CircleCI UI. CodeFresh doesn't have this ability (AFAIK) so that can only be re-run by a new commit. |
08df399
to
70f37a8
Compare
@petebacondarwin: That's a new one! Will be usefull! Thanks! |
@JoostK @petebacondarwin - the build seems to fail. And I have no idea what the error message means. |
@JonWallsten neither do I, it seems like a flake. I restarted the workflow for you, lets hope that resolves the issue. |
LOL! So did I. I'll leave @JoostK to help out here. I think it was probably a flake. |
@JoostK @petebacondarwin: Weird! Happends twice in a row. That's why I thought it was a real error. But third times the charm it seems! Thanks guys! |
70f37a8
to
cc33dc0
Compare
@JoostK: Let me know if there's anything more you'd need me to do! |
// location. | ||
// We return 'redirectInfo.unredirected' to return the original file and not the, by | ||
// TypeScript, suggested target file. | ||
if ((summary.sourceFile as any).redirectInfo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer the code to read as follows:
sf = summary.sourceFile;
const redirectInfo = (sf as any).redirectInfo;
if (redirectInfo !== undefined) {
sf = redirectInfo.unredirected;
}
@@ -39,6 +39,12 @@ export class TypeCheckProgramHost implements ts.CompilerHost { | |||
sf = this.delegate.getSourceFile( | |||
fileName, languageVersion, onError, shouldCreateNewSourceFile); | |||
sf && this.sfMap.set(fileName, sf); | |||
} else if ((sf as any).redirectInfo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here, I think the following reads better:
} else {
const redirectInfo = (sf as any).redirectInfo;
if (redirectInfo !== undefined) {
sf = redirectInfo.unredirected;
}
}
Maybe the comment should mention that offering the redirect source file is not allowed by TypeScript, hence the effort to obtain the original source file.
64361a2
to
5bd001a
Compare
…ourceFile from getSourceFile Closes angular#22524
5bd001a
to
9bd0e96
Compare
@JoostK: Done! Probably what have taken you much less time to do this yourself. I feel like a middleman! ;) |
@JonWallsten thank you for your perseverance! It is much appreciated 👍The compiler master @alxhub is not available this week, but I am pretty confident we can get this approved and merged soon. |
@JonWallsten many thanks for your contribution here! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
merge-assistance: please run presubmit |
That moment when you first encounter a really annoying Angular bug, only to realize that other people have been dealing with it for over a year and just fixed it for you. Thank you @JonWallsten!!!!!! 🎉 🎉 🎊 |
…ourceFile from getSourceFile (angular#26036) Closes angular#22524 PR Close angular#26036
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
When using webpack dev server and AngularCompilerPlugin (maybe other combinations as well) all but the first compile always fails with the the following error:
The problem is causes by duplicated definition files with different paths.
Example:
Typescript expects the redirect's target instead of the redirects source.
This fix solves that.
Issue Number: #22524
What is the new behavior?
The error message is not thrown. Fix is borrowed from here: ng-packagr/ng-packagr@c1fced0
Does this PR introduce a breaking change?
Other information
This is definitely a hotfix. I don't have enough knowledge about TypeScript to solve the root cause. But this has been stopping our project since March, and based ont he up votes on the issue I'm not the only one.