1
votes

I'm trying to compile an angular 2 app using AOT. In my project I'm using angular-2-json-schema-form and it's causing errors like this:

Property is private and only accessible within class

when compiling my app.

I think that problem is in TypeScript. Somebody help me resolve this problem.

2
Post your code if you expect help - Sajeetharan
you're accessing a private field in a template. Don't do that. - drew moore
I'm not accessing a private field in template. I'm just using this package npmjs.com/package/angular2-json-schema-form and all problems in it - Noob
@drewmoore, is there some tsconfig property which can disable such typescript behavior? - Noob
@Noob no - it's not tsc that's throwing, it's ngc, and this is by design. If the error is coming out of that library, it should be filed as a bug against their repo. - drew moore

2 Answers

1
votes

Per this GitHub Issue, it's because prod builds use Ahead of Time compilation by default. You can work around it by turning off AOT, or by using public properties.

1
votes

The most probable problem is that you have in a component.html some like {{myService.value}} or you have a enum and use directy in your component.html (e.g. .

If you are using myService.value, use a getter

get value(){
   return myService.value;
}
//in your .html
{{value}}

If your problem is because you're using an enum, declare a variable

IEnum=Enum

//in your .html
<div *ngIf="value==IEnum.Case1">