Ionic-app-scripts: ngc Error: Property 'string' does not exist on type...

Created on 8 Oct 2016  路  3Comments  路  Source: ionic-team/ionic-app-scripts

Short description of the problem:

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.

What behavior are you expecting?

ngc should not throw an error(?)

Steps to reproduce:

  1. Create a class with a string variable in the constructor.
  2. Include said class in app.module.ts
  3. Run $ npm run build or $ ionic run android or $ ionic run ios

Which @ionic/app-scripts version are you using?
0.0.30

Most helpful comment

If anyone is getting this error, [this issue] (https://github.com/angular/angular/issues/12551) could be of same help.

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandyscarney picture brandyscarney  路  4Comments

peterpeterparker picture peterpeterparker  路  4Comments

janpio picture janpio  路  3Comments

MarkErik picture MarkErik  路  3Comments

danbucholtz picture danbucholtz  路  4Comments