How to fix error: Multiple constructor implementations are not allowed

when i want to build:

ionic cordova build --release android

i get the following error message:

Multiple constructor implementations are not allowed.

l27: constructor(public navCtrl: NavController, public http: HttpClient) {

→ how can i fix this? thx :slight_smile:

How about by having only one constructor for that class?

This. Multiple/overloading constructors is common practice in Java applications but not so much in Typescript. In fact I have never seen it done via typescript and am not sure why it would be.

Even if there is a good reason, looks like it leads to a dead end

Because it’s impossible. JavaScript does not have runtime type information, so function overloading (including constructors) cannot be done. Arguments are not part of a function’s signature.

1 Like

That’s a pretty solid reason for avoiding the practice. And a great explanation for why an error would be thrown in the process.

Also a good example of the deceptive similarities between TypeScript and Java. At this point I’m writing mostly in Java and can say there are few similarities despite appearances.