@angular/compiler-cli: Missing Property access check for ngtsc
See original GitHub issueš 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:
bazel-out/host/bin/tools/bazel_rules/tsc_wrapped_with_angular.sh @@bazel-out/darwin-fastbuild/bin/libs/barista-components/drawer/compile_es5_tsconfig.json)
Execution platform: @local_config_platform//:host
Compilation failed TypeError: Cannot read property '0' of undefined
at Object.typeToValue (/private/var/tmp/_bazel_lukas.holzer/14b203e5dd3ee3cb631c98babb73d5eb/execroot/dynatrace/bazel-out/host/bin/tools/bazel_rules/tsc_wrapped_with_angular.sh.runfiles/npm/node_modules/@angular/compiler-cli/src/ngtsc/reflection/src/type_to_value.js:57:66)
at /private/var/tmp/_bazel_lukas.holzer/14b203e5dd3ee3cb631c98babb73d5eb/execroot/dynatrace/bazel-out/host/bin/tools/bazel_rules/tsc_wrapped_with_angular.sh.runfiles/npm/node_modules/@angular/compiler-cli/src/ngtsc/reflection/src/typescript.js:75:58
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 property declarations
{
"flags": 33554436,
"escapedName": "unknown",
"checkFlags": 0,
"type": {
"checker": {},
"flags": 1,
"id": 4,
"intrinsicName": "error",
"objectFlags": 0
}
}
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.
constructor(
private _elementRef: ElementRef,
private _breakpointObserver: BreakpointObserver,
) {...}
š Your Environment
"version": "10.0.14"
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (7 by maintainers)
Top GitHub Comments
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.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.