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): various improvements to import generation logic #44587
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6dd5103
to
dd9e5d7
Compare
dd9e5d7
to
18c298e
Compare
dario-piotrowicz
reviewed
Dec 31, 2021
packages/compiler-cli/src/ngtsc/typecheck/src/type_parameter_emitter.ts
Outdated
Show resolved
Hide resolved
alxhub
approved these changes
Jan 4, 2022
AndrewKushnir
reviewed
Jan 5, 2022
In certain scenarios, the compiler may have crashed with an `Unable to write a reference` error which would be particularly hard to diagnose. One of the primary reasons for this failure is when the `rootDir` option is configured---typically the case for libraries--- and a source file is imported using a relative import from an external entry-point. This would normally report TS6059 for the invalid relative import, but the crash prevents this error from being surfaced. This commit refactors the reference emit logic to result in an explicit `Failure` state with a reason as to why the failure occurred. This state is then used to report a `FatalDiagnosticException`, preventing a hard crash. Closes angular#44414
…ce file path Using `absoluteFromSourceFile` leverages the cache of the resolved absolute path, instead of having to compute it each time.
This commit fixes an issue with symlink handling in `MockFileSystem`, where entries within a symlink would fail to resolve.
The `NgtscCompilerHost` is implemented using the `FileSystem` abstraction of the compiler, which is implemented for tests using an in-memory `MockFileSystem`. If the in-memory filesystem contains symlinks, then using `NgtscCompilerHost` would not reflect their resolved real path. Instead, the TypeScript compiler would use its default implementation based on the real filesystem, which is unaware of the in-memory `MockFileSystem` setup. This change does not currently address any issues, but is being fixed as it prevented a reproduction scenario from behaving correctly.
When building a library, the `rootDir` option is configured to ensure that all source files are present within the entry-point that is being build. This imposes an extra constraint on the reference emit logic, which does not allow emitting a reference into a source file outside of this `rootDir`. During the generation of type-check blocks we used to make a best-effort estimation of whether a type reference can be emitted into the type-check file. This check was relaxed in angular#42492 to support emitting more syntax forms and type references, but this change did not consider the `rootDir` constraint that is present in library builds. As such, the compiler might conclude that a type reference is eligible for emit into the type-check file, whereas in practice this would cause a failure. This commit changes the best-effort estimation into a "preflight" reference emit that is fully accurate as to whether emitting a type reference is possible. Fixes angular#43624
18c298e
to
118ddcc
Compare
caretaker note: please review the presubmit failure and merge if possible, as I hope they're flakes. |
This PR was merged into the repository by commit f8af49e. |
atscott
added a commit
that referenced
this issue
Jan 6, 2022
…44587) The `NgtscCompilerHost` is implemented using the `FileSystem` abstraction of the compiler, which is implemented for tests using an in-memory `MockFileSystem`. If the in-memory filesystem contains symlinks, then using `NgtscCompilerHost` would not reflect their resolved real path. Instead, the TypeScript compiler would use its default implementation based on the real filesystem, which is unaware of the in-memory `MockFileSystem` setup. This change does not currently address any issues, but is being fixed as it prevented a reproduction scenario from behaving correctly. PR Close #44587
atscott
added a commit
that referenced
this issue
Jan 6, 2022
…44587) When building a library, the `rootDir` option is configured to ensure that all source files are present within the entry-point that is being build. This imposes an extra constraint on the reference emit logic, which does not allow emitting a reference into a source file outside of this `rootDir`. During the generation of type-check blocks we used to make a best-effort estimation of whether a type reference can be emitted into the type-check file. This check was relaxed in #42492 to support emitting more syntax forms and type references, but this change did not consider the `rootDir` constraint that is present in library builds. As such, the compiler might conclude that a type reference is eligible for emit into the type-check file, whereas in practice this would cause a failure. This commit changes the best-effort estimation into a "preflight" reference emit that is fully accurate as to whether emitting a type reference is possible. Fixes #43624 PR Close #44587
atscott
added a commit
that referenced
this issue
Jan 6, 2022
In certain scenarios, the compiler may have crashed with an `Unable to write a reference` error which would be particularly hard to diagnose. One of the primary reasons for this failure is when the `rootDir` option is configured---typically the case for libraries--- and a source file is imported using a relative import from an external entry-point. This would normally report TS6059 for the invalid relative import, but the crash prevents this error from being surfaced. This commit refactors the reference emit logic to result in an explicit `Failure` state with a reason as to why the failure occurred. This state is then used to report a `FatalDiagnosticException`, preventing a hard crash. Closes #44414 PR Close #44587
atscott
added a commit
that referenced
this issue
Jan 6, 2022
…44587) The `NgtscCompilerHost` is implemented using the `FileSystem` abstraction of the compiler, which is implemented for tests using an in-memory `MockFileSystem`. If the in-memory filesystem contains symlinks, then using `NgtscCompilerHost` would not reflect their resolved real path. Instead, the TypeScript compiler would use its default implementation based on the real filesystem, which is unaware of the in-memory `MockFileSystem` setup. This change does not currently address any issues, but is being fixed as it prevented a reproduction scenario from behaving correctly. PR Close #44587
atscott
added a commit
that referenced
this issue
Jan 6, 2022
…44587) When building a library, the `rootDir` option is configured to ensure that all source files are present within the entry-point that is being build. This imposes an extra constraint on the reference emit logic, which does not allow emitting a reference into a source file outside of this `rootDir`. During the generation of type-check blocks we used to make a best-effort estimation of whether a type reference can be emitted into the type-check file. This check was relaxed in #42492 to support emitting more syntax forms and type references, but this change did not consider the `rootDir` constraint that is present in library builds. As such, the compiler might conclude that a type reference is eligible for emit into the type-check file, whereas in practice this would cause a failure. This commit changes the best-effort estimation into a "preflight" reference emit that is fully accurate as to whether emitting a type reference is possible. Fixes #43624 PR Close #44587
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
See individual commits.
Closes #44414
Fixes #43624