question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

@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

image

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. image

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

@angular/compiler-cli

"version": "10.0.14"

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
JoostKcommented, Sep 2, 2020

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.

0reactions
angular-automatic-lock-bot[bot]commented, Oct 11, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrade from Angular 8 to v12 causing "Generating browser ...
I have been working on upgrading an angular app from v8 to v12. ... /@angular/compiler-cli/ngcc/src/host/umd_host.js:519:99) at Object.
Read more >
Angular compiler options
The extends property is at the top level, parallel to compilerOptions and angularCompilerOptions . A TypeScript configuration can inherit settings from anotherĀ ...
Read more >
Angular 9's Best Hidden Feature: Strict Template Checking
Angular 9 and the Ivy compiler do just that. ... Strict Template Check Error for missing property on a model. This last error...
Read more >
Type-checking templates in Angular ViewEngine and Ivy
const { TypeCheckFile } = require('./node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_file.js'); const old = TypeCheckFile.prototype.renderĀ ...
Read more >
How to fix property not existing on EventTarget in TypeScript
This error occurs when you try to access a property on an event ... If you compile the above snippet, the compiler will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found