My app works fine when using ionic serve. However, when I run a build (e.g. ionic run android), ngc will throw an error:
[21:56:25] ngc: Error: Error at D:/Users/User/Desktop/project/.tmp/app/app.module.ngfactory.ts:587:140: Property 'string' does not exist on type 'typeof "D:/Users/User/Desktop/project/.tmp/providers/firebase.service"'.
at check (D:\Users\User\Desktop\project\node_modules\@angular\tsc-wrapped\src\tsc.js:31:15)
at Tsc.typeCheck (D:\Users\User\Desktop\project\node_modules\@angular\tsc-wrapped\src\tsc.js:86:9)
at D:\Users\User\User\project\node_modules\@angular\tsc-wrapped\src\main.js:33:23
at process._tickCallback (internal/process/next_tick.js:103:7)
at Module.runMain (module.js:592:11)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
The constructor code in question is below:
Injectable()
export class FirebaseService extends AngularFire {
...
constructor(firebaseConfig: string, auth: AngularFireAuth, database: AngularFireDatabase) {
super(firebaseConfig, auth, database)
}
...
}
Some people on the forum have worked around this by removing all mention of string in the constructor, but because I am extending from the AngularFire class, I must state the super call as is.
ngc should not throw an error(?)
Steps to reproduce:
string variable in the constructor.app.module.ts$ npm run build or $ ionic run android or $ ionic run iosWhich @ionic/app-scripts version are you using?
0.0.30
Had same problem, feel this is related that on ionic.modules when the provider is declared, there is no string. My solution was to make the class abstract, remove it from [providers] app.modules.ts and just make that every other class using it is extending it.
export abstract class FirebaseService extends AngularFire {
}
Hello, sorry for the delay on this one! This is actually an NGC error and not an Ionic error. NGC is the AoT compiler that the Angular team is building. It has the ability to do typechecking of variables and methods that are bound to your templates, it is also very strict in its typechecking. Since NGC is an Angular project i am going to close this issue and ask that you open an issue on the Angular repo. Thanks!
If anyone is getting this error, [this issue] (https://github.com/angular/angular/issues/12551) could be of same help.
Most helpful comment
If anyone is getting this error, [this issue] (https://github.com/angular/angular/issues/12551) could be of same help.