NativeScript iOS Delegate Transpilation error (Can't find variable: __metadata)

1.1k views Asked by At

I'm attempting to implement an iOS delegate in a NativeScript plugin and am getting an error:

Terminating app due to uncaught exception 'NativeScript encountered a fatal error: ReferenceError: Can't find variable: __metadata

My original code is:

@ObjCClass(SQRDCheckoutControllerDelegate) export class SquareReader extends NSObject implements SQRDCheckoutControllerDelegate { /* iOS delegate implementation here (source https://docs.connect.squareup.com/payments/readersdk/setup-ios) */ }

And that's getting transpiled in js down to:

SquareReader = __decorate([ ObjCClass(exports.SQRDCheckoutControllerDelegate), __metadata("design:paramtypes", []) ], SquareReader);

If I just remove the __metadata line, I get a different error:

Terminating app due to uncaught exception 'NativeScript encountered a fatal error: Error: Protocol "undefined" is not a protocol object.

Any ideas? I've seen other examples like nativescript-image-swipe where the code is being transpiled w/o the __metadata method leading me to think something might be wrong with the transpilation

1

There are 1 answers

0
Frank On BEST ANSWER

I solved this by cleaning up my typings. I just re-ran the command to generate typings: TNS_TYPESCRIPT_DECLARATIONS_PATH="$(pwd)/typings" tns build ios and put them in my /src directory for my plugin. Once my typings were correct the project ran as expected and the Delegate worked