4

I wonder about any available typings for cloudboost.io https://github.com/CloudBoost/JavaScriptSDK. I have no experience with writing typings for existing js modules. I was trying to prepare any dumbest d.ts but with no success. i.e. using ionic2 and npm install cloudboost (also currently its required to separately npm install fs) I was trying to use cloudboost.d.ts like.

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 i.e.

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. So even any dumb object would satisfy me for the beginning.

animuson
  • 53,861
  • 28
  • 137
  • 147
ciekawy
  • 2,238
  • 22
  • 35

1 Answers1

1

We don't have typescript typing for CloudBoost JavaScript SDK yet, but you should be able to create one yourself.

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

Here is a sample TypeScript project that uses this sample module https://github.com/basarat/ts-npm-module-consume

Basically you need to :

compile with commonjs and declaration:true

generate a .d.ts file

And then

Have your ide read the generated .d.ts.

Let me know if this helps.

-Nawaz CloudBoost.io Support Staff

Nawaz Dhandala
  • 2,046
  • 2
  • 17
  • 23
  • Let me know if you can create one, and if you want to contribute to the repo. Send us the PR. :) Here's the another link that might help : https://github.com/Microsoft/TypeScript/wiki/Typings-for-npm-packages – Nawaz Dhandala Jan 20 '16 at 12:45
  • thanks for hints! actually in the answer the original npm module is already a typescript one but I'll keep trying anyway. the MS resource sounds helpful though... – ciekawy Jan 20 '16 at 15:36