How to force "invalid" Typescript to compile straight into JS?

时间:2016-04-25 09:15:21

标签: android typescript nativescript

I am writing a plugin for Nativescript, in TS. I am following this guide to reference an android java SDK that I want to use. Essentially, to target a library's platform specific API's, you have to call them relative to their gradle import values - like so.

In my TS, I have the following line:

var mClient = new com.Microsoft.azure.MobileServiceClient();

which I believe should be fine, despite the errors, but unfortunately, it is causing tsc to fail -

nsAzure.android.ts(7,27): error TS2304: Cannot find name 'com'

How can I get this to transpile literally into js and continue with the build and ideally not spit errors or warnings into my log?

1 个答案:

答案 0 :(得分:2)

If you really just want to silence the error:

declare var com: any;
var mClient = new com.Microsoft.azure.MobileServiceClient();

Ideally you would get a .d.ts file that described com though.