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.

ngcc generates invalid property metadata

See original GitHub issue

🐞 bug report

Affected Package

@angular/compiler-cli / ngcc

Description

Currently when compiling @angular/cdk/a11y with ngcc, the generated property metadata call (setClassMetadata) incorrectly sets metadata for the autoCapture property within the FocusTrap twice.

Ι΅ngcc0.Ι΅setClassMetadata(..., {
  autoCapture: [{
      type: Input,
      args: ['cdkTrapFocusAutoCapture']
    }], 
  autoCapture: [], 
});

This means that the first occurrence will be accidentally overwritten and the metadata is discarded. The duplication seems to happen because autoCapture declares a getter and a setter.

As far as I could tell the issue is that ngcc returns the getter and setter for reflection.getMembersOfClass(FocusTrap) but sets decorators that are either defined on getter or setter as decorators for both members. This then results in two properties with the same name in the setClassMetadata call.

https://github.com/angular/angular/blob/master/packages/compiler-cli/src/ngtsc/annotations/src/metadata.ts#L59-L62

πŸ”¬ Minimal Reproduction

https://github.com/devversion/ivy-ngcc-generates-duplicate-prop-metadata

πŸ”₯ Exception or Error

See: https://github.com/angular/components/issues/16066

Defining the same property multiple times seems to cause an exception in IE11 with use strict mode. This is actually reasonable as the first declaration is accidentally overwritten in an object literal.

🌍 Your Environment

Angular Version:


@angular/*: 8.0.0-rc.4
@angular/cdk: 8.0.0-rc.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:14
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
Splaktarcommented, Sep 18, 2019

Is freq1: low correct for this issue? It seems a little low for an issue that breaks apps on an entire, supported, browser?

2reactions
M4R1KUcommented, Dec 2, 2019

@nmainardi It is fixed in 9.0.0-rc.3. You have to upgrade to atleast this version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NG6999: Invalid @NgModule() metadata - Angular
This error represents the import or export of an @NgModule() that doesn't have valid metadata. Debugging the errorlink. The library might have been...
Read more >
Upgrade from Angular 8 to v12 causing "Generating browser ...
I was experiencing this same issue after an upgrade. What finally fixed it for me was deleting package-lock.json.
Read more >
Top 10 Features in Angular 13 Every Developer Should Know
This article explains the top 10 features in Angular 13 that every Angular developer should know and helps you decide whether to upgrade...
Read more >
@angular/compiler | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Angular 12 in Depth - SΓ©bastien Dubois
What ngcc does is compile libraries that rely on View Engine so that Ivy can ... Angular now generates less code for safe...
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