Android nativescript扩展jar类引发异常

Android nativescript扩展jar类引发异常,android,nativescript,Android,Nativescript,我使用nativescript+tyepscript需要扩展androidjar,但它会抛出异常 “类型“any”不是构造函数类型。” declare var com : any; export class MyPushTestReceives extends com.baidu.android.pushservice.PushMessageReceiver.extend { static constructorCalled: boolean = false; // //construct

我使用nativescript+tyepscript需要扩展androidjar,但它会抛出异常 “类型“any”不是构造函数类型。”

declare var com : any;

export class MyPushTestReceives extends 
com.baidu.android.pushservice.PushMessageReceiver.extend {
static constructorCalled: boolean = false;

// //constructor
init() {
    MyPushTestReceives.constructorCalled = true;

    // necessary when extending TypeScript constructors
    return global.__native(this);
}
}

您应该在Java类上使用TypeScript类扩展语法或调用
.extend({})
的JavaScript方式,但不能同时使用这两种方式

因此,删除不必要的.extend应该可以解决您的问题:

export class MyPushTestReceives extends com.baidu.android.pushservice.PushMessageReceiver