简体   繁体   English

如何通过打字稿使用NativeScript插件?

[英]How to use NativeScript plugin through typescript?

I'm using EddyVerbruggen's Firebase plugin( https://github.com/EddyVerbruggen/nativescript-plugin-firebase ) in one of my NativeScript application. 我在我的NativeScript应用程序之一中使用EddyVerbruggen的Firebase插件( https://github.com/EddyVerbruggen/nativescript-plugin-firebase )。

Also, I'm the first time using TypeScript in this project. 另外,我还是第一次在此项目中使用TypeScript。 I've setup everything as it's given in their documentation. 我已经按照他们的文档中的说明进行了设置。 But, can't able to understand how to use their code in TypeScript. 但是,无法理解如何在TypeScript中使用其代码。

Ex: 例如:

 var firebase = require("nativescript-plugin-firebase");

  firebase.init({
    persist: true // Allow disk persistence. Default false.
  }).then(
      function (instance) {
        console.log("firebase.init done");
      },
      function (error) {
        console.log("firebase.init error: " + error);
      }
  );

Can't able to understand how to use above code in Typescript. 无法理解如何在Typescript中使用以上代码。 Any documentation or tutorial link will be a great help. 任何文档或教程链接都将提供很大的帮助。

Regards 问候

All JavaScrip is valid TypeScript, there is not need for any additional changes. 所有JavaScrip都是有效的TypeScript,无需进行任何其他更改。 The above JavaScript calls are 100% valid in TypeScript and should not lead to any errors or warnings. 上面的JavaScript调用在TypeScript中100%有效,不应导致任何错误或警告。

Here is a quick quote from www.typescriptlang.org : 这是来自www.typescriptlang.org的快速报价:

Types enable JavaScript developers to use highly-productive development tools and practices like static checking and code refactoring when developing JavaScript applications. 类型使JavaScript开发人员可以在开发JavaScript应用程序时使用高效的开发工具和做法,例如静态检查和代码重构。

Types are optional, and type inference allows a few type annotations to make a big difference to the static verification of your code. 类型是可选的,并且类型推论允许一些类型的注释对代码的静态验证产生很大的影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM