Struggling to define a JavaScript function in TypeScript? Here is the issue:
Take a look at the code snippet below and see what needs support from the TS definition file:
myfile.ts:
this._scanCallback = new android.bluetooth.BluetoothAdapter.LeScanCallback({
onLeScan: function (device: android.bluetooth.BluetoothDevice, rssi: number, scanRecord: Array<number>) {
// FUNCTIONALITY ...
}
})
The current definition file isn't working as expected for onLeScan()
. Let's review it:
def.d.ts:
export module android {
export class bluetooth {
export class BluetoothAdapter extends java.lang.Object {
static xyz: number;
public abcd(): boolean;
}
export namespace BluetoothAdapter {
export class LeScanCallback(
onLeScan(device: android.bluetooth.BluetoothDevice, rssi: number, scanRecord: Array<number>): void;
){}
}
}
}
To make sure the snippet in myfile.ts passes ts compilation successfully, we need to fix the
android.bluetooth.BluetoothAdapter.LeScanCallback()
function. Currently, an error message is received:
[ts] Supplied parameters do not match any signature of call target. constructor android.bluetooth.BluetoothAdapter.LeScanCallback(): android.bluetooth.BluetoothAdapter.LeScanCallback
If you have suggestions or solutions for how the definition should be adjusted, please share your insights.