android - 如何强制 "invalid"Typescript 直接编译成 JS?

标签 android typescript nativescript

我正在为 Nativescript 写一个插件, 在 TS 中。我正在关注 this引用我想使用的 android java SDK 的指南。本质上,要针对库的平台特定 API,您必须相对于它们的 gradle 导入值来调用它们 - 就像这样。

在我的 TS 中,我有以下行:

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

我认为应该没问题,尽管有错误,但不幸的是,它导致 tsc 失败 -

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

我怎样才能将其直接转换成 js 并继续构建,最好不要将错误或警告吐到我的日志中?

最佳答案

如果你真的只想消除错误:

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

理想情况下,您会得到一个描述 com 的 .d.ts 文件。

关于android - 如何强制 "invalid"Typescript 直接编译成 JS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36836366/

相关文章:

javascript - native 脚本 : How to pass object from Page to Custom component with data-binding?

nativescript - 在应用程序中实现多语言的最佳方法是什么?

android - Google Places Android 显示错误 "place fields must not be empty"?

android - 异常(exception):重复条目:android/support/v7/widget/CardViewApi21.class

typescript - 如何限制 typescript 中的枚举字符串值

reactjs - 理解 typescript 中的 `as unknown as`

在 Web Worker 中导入 tensorflow 时出现 Angular typescript 类型检查问题

javascript - 在 Nativescript Angular 应用程序中,application.start()/run() 在哪里?

android - 简单的补间动画示例

android - 如何在 Android 中更新 TextView 的文本?