I have an Android-Java class that have two overloaded methods
package com.test;
public class A{
public void theMethod(Bitmap bitmap){
...
}
public void theMethod(int resource){
...
}
}
And I am trying to extends the class in a Nativescript-Angular program:
class ExtendedA extends com.test.A{
public theMethod(bitmap : android.graphics.Bitmap) : void{
...
}
}
but I have this error
Property 'theMethod' in type 'ExtendedA' is not assignable to the same property in base type ‘A’.
Type ‘(bitmap : Bitmap) => void' is not assignable to type '{ (param: Bitmap): void; (param : number): void; }'.
Types of parameters 'bitmap' and 'param' are incompatible.
Type 'number' is not assignable to type 'Bitmap'.
P.D. I have not the class com.test.A code.
In your tsconfig.json file you need to make --strictFunctionTypes:true.
"compilerOptions": {
"module": "commonjs",
"strictFunctionTypes": true,
"downlevelIteration": true
}
P.S. if your argument count is different in Class A then Java method overloads are handled by the developer by explicitly checking the arguments count of the invoked function.