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
@angular/compiler-cli: Missing Property access check for ngtsc #38670
Comments
β¦value conversion The type-to-value conversion could previously crash if a symbol was resolved that does not have any declarations, e.g. because it's imported from a missing module. This would typically result in a semantic TypeScript diagnostic and halt further compilation, therefore not reaching the type-to-value conversion logic. In Bazel however, it turns out that Angular semantic diagnostics are requested even if there are semantic TypeScript errors in the program, so it would then reach the type-to-value conversation and crash. This commit fixes the unsafe access and adds a test that ignores the TypeScript semantic error, effectively replicating the situation as experienced under Bazel. Fixes angular#38670
We're typically quite meticulous when it comes to checking for the existence of declarations, this one appears to have slipped (for the record, it was me a couple weeks ago π). Anyway, the situation you experienced the issue with would not normally crash the compilation when using ngc, as ngc halts the compilation when there's TypeScript semantic errors. I noticed however that you're using Bazel which seems to request Angular semantic diagnostics regardless of semantic TS errors, therefore resulting in a hard crash at the point you identified. Fix in #38684. |
Hey awesome how fast this is being tackled! π Yeah, using the wrapped tsc with bazel. I really love the strict dependency checks so that was the last point I thought that it is a missing dep that caused the problem. But was actual fun to find the bug :D |
I just ran into this same problem (in type_to_value.js), but am not using bazel. Let me dig up more details and see if I can reproduce |
The problem has sporadically appeared for me today. One thing I noticed is that if I rename a service file to an unorthodox extension (say, 'my.service.ts' --> 'my.messages.ts'), it sometimes throws this error. I'm also exporting the |
β¦value conversion (#38684) The type-to-value conversion could previously crash if a symbol was resolved that does not have any declarations, e.g. because it's imported from a missing module. This would typically result in a semantic TypeScript diagnostic and halt further compilation, therefore not reaching the type-to-value conversion logic. In Bazel however, it turns out that Angular semantic diagnostics are requested even if there are semantic TypeScript errors in the program, so it would then reach the type-to-value conversation and crash. This commit fixes the unsafe access and adds a test that ignores the TypeScript semantic error, effectively replicating the situation as experienced under Bazel. Fixes #38670 PR Close #38684
I'm hitting the error again, but I don't quite understand the cause. The value of decl right before the error is:
and I just get the same error " |
@s4m0r4m4 Can you update to 10.1.1, which was released yesterday? |
Hi @JoostK, I upgraded to 10.1.1 and did a rebuild. It spit out a lovely error message that described the issue (I was importing "path" in an angular application running in electron, and it was causing some issues). From there I was able to debug and fix the issue, thank you for your quick response! |
@s4m0r4m4 Excellent, I was hoping that would be the case. |
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. |
π bug report
Affected Package
@angular/compiler-cli βΒ ngtsc
Is this a regression?
No, I don't think so.
Description
In the
typeToValue
function of the ngtsc there is a missing property access check so that the typescript compile fails with an error that does not provide the right context. It is okay that it is failing but it should print something like "it cannot resolve the typeNode as the dependency could not be found" instead of:node_modules/@angular/compiler-cli/src/ngtsc/reflection/src/type_to_value.js on line 46
If I print the
decl
I can see that there is no propertydeclarations
Instead of failing with the property access, it would be nice to have an error, that it could not resolve the package.
The error occurred because it could not find the
BreakpointObserver
in the constructor. But it should error earlier on it cannot resolve the import if the package cannot be found.π Your Environment
@angular/compiler-cli
The text was updated successfully, but these errors were encountered: