简体   繁体   English

cloudboost的打字稿类型(并与ionic2一起使用)

[英]Typescript typings for cloudboost (and use it with ionic2)

I wonder about any available typings for cloudboost.io https://github.com/CloudBoost/JavaScriptSDK . 我想知道cloudboost.io https://github.com/CloudBoost/JavaScriptSDK的任何可用类型。 I have no experience with writing typings for existing js modules. 我没有为现有的js模块编写打字的经验。 I was trying to prepare any dumbest d.ts but with no success. 我试图准备任何最愚蠢的d.ts但没有成功。 ie using ionic2 and npm install cloudboost (also currently its required to separately npm install fs ) I was trying to use cloudboost.d.ts like. 即使用ionic2和npm install cloudboost (目前还需要单独npm install fs )我试图使用cloudboost.d.ts类的。

declare module "cloudboost" {}

or 要么

declare var CB: any;
declare module "cloudboost" {
  export var CB: any;
}

the result is strange as cloudboost is included to ionic2 build (using it's webpack config) however when using ie 结果是奇怪的,因为cloudboost包含在ionic2 build(使用它的webpack配置)但是当使用ie时

import * as CB from "cloudboost";

or similar import variants gives in return CB value of some socket.io object even if the inner webpack call seems to refer to proper cloudboost code. 或者类似的import变量给出了一些socket.io对象的CB值,即使内部webpack调用似乎引用了正确的cloudboost代码。 So even any dumb object would satisfy me for the beginning. 因此,即使是any愚蠢的物体也会让我满意。

We don't have typescript typing for CloudBoost JavaScript SDK yet, but you should be able to create one yourself. 我们还没有为CloudBoost JavaScript SDK输入打字稿,但您应该可以自己创建一个。

Here's what I found after looking up on SO for this issue. 这是我在查找此问题后找到的内容。

Here is a sample Node module written in TypeScript : https://github.com/basarat/ts-npm-module 以下是使用TypeScript编写的Node模块示例: https//github.com/basarat/ts-npm-module

Here is a sample TypeScript project that uses this sample module https://github.com/basarat/ts-npm-module-consume 下面是一个使用此示例模块的示例TypeScript项目https://github.com/basarat/ts-npm-module-consume

Basically you need to : 基本上你需要:

compile with commonjs and declaration:true 使用commonjs和declaration编译:true

generate a .d.ts file 生成.d.ts文件

And then 然后

Have your ide read the generated .d.ts. 你的ide读取生成的.d.ts。

Let me know if this helps. 如果这有帮助,请告诉我。

-Nawaz CloudBoost.io Support Staff -Nawaz CloudBoost.io支持人员

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

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