angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Allow option to suppress duplicate errors in angular -cli

Open abidmix opened this issue 9 years ago • 5 comments

Bug Report or Feature Request (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ x] feature request

Versions.

C:\PMLCLI\Phoenix\Phoenix_LMS\Phoenix.Web>ng --version _ _ ____ _ ___ / \ _ __ __ _ _ | | __ _ _ __ / | | | | / △ \ | ' \ / _ | | | | |/ _ | '| | | | | | | / ___ | | | | (| | || | | (| | | | || | | | // __| ||_, |_,||_,|| _||| |___/ @angular/cli: 1.4.4 node: 6.11.3 os: win32 x64 @angular/animations: 4.4.6 @angular/common: 4.4.6 @angular/compiler: 4.4.6 @angular/core: 4.4.6 @angular/forms: 4.4.6 @angular/http: 4.4.6 @angular/material: 2.0.0-beta.8 @angular/platform-browser: 4.4.6 @angular/platform-browser-dynamic: 4.4.6 @angular/router: 4.4.6 @angular/upgrade: 4.4.6 @angular/cli: 1.4.4 @angular/compiler-cli: 4.4.4 typescript: 2.3.4

Windows (10)

Repro steps.

image

The log given by the failure.

Duplicate Identifier in component

Desired functionality.

Allow me to suppress duplicate errors or let duplicate errors not affect the emitting of code in the dist folder. I do not see any duplicate identifier in my code and the ng.factory file is never outputted which leaves me with nothing to debug.

Mention any other details that might be useful.

In my template I have code like this and I do not see why 'active' is marked as a a duplicate identifier. This code works perfecttly fine in JIT.

<li class="listmathSubDomain" *ngFor="let subdomain of subjectVM.subDomainArray" [ngClass]="{'active': subdomain.Description == subjectVM.SelectedSubDomain}">

abidmix avatar Oct 19 '17 19:10 abidmix

It seems this line was the culprit in AOT.

[ngClass]="{'active': math.Name == subjectVM.SelectedMathDomain,'active': math.Title == subjectVM.SelectedDomain}"

And changed it to [ngClass]="{'active': (math.Name == subjectVM.SelectedMathDomain || math.Title == subjectVM.SelectedDomain)}"

But I still feel this should not stop the whole build

abidmix avatar Oct 19 '17 21:10 abidmix

The root cause is that the code example is creating an object literal with the same property name twice. If that was done in an actual js/ts file there would be a compiler error as well.

Also, instead of using ngClass you can also use [class.active]="<condition>". It's not only more concise but less error prone as well.

clydin avatar Oct 19 '17 22:10 clydin

It's a somewhat an unfortunate error, but it's not something we're going to ignore. It is a real error in building an app that should be ignored. But it should be reported by @angular/compiler instead of emitted as invalid code IMHO. Can you open this issue in https://github.com/angular/angular instead please?

filipesilva avatar Oct 25 '17 09:10 filipesilva

@filipesilva Thanks. I re-opened the issue here

abidmix avatar Oct 27 '17 20:10 abidmix

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.