Phil
Phil

Reputation: 3043

Typescript specific methods for saving data online?

I'm thinking about using TypeScript to create an online app, and this will require saving of data online.

  1. What are my options in regards to that?
  2. Is there anything specific to using TypeScript which makes that easier or harder?
  3. Ideally I would use a service like Parse.com to save data, can Typescript be connected to Parse or would I have to rely upon plain JS?

Upvotes: 1

Views: 503

Answers (1)

basarat
basarat

Reputation: 275799

TypeScript runs wherever javascript runs. So

  • Your options are the same as javascript.

Typescript compiles down to javascript. And it is designed to be a superset of javascript so your javascript will be valid typescript as long as you have variables declared and sometimes types mentioned.

  • Optional static typing + easier syntax is what makes developing in TypeScript easier.

Static typing makes refactoring and intellisense more reliable. Having an easier syntax for classes / modules means you are more likely to structure your code better.

  • Yes you can use parse.com with typescript

The recommended way to do that is to create a declaration file describing your javascript code. In the beginning it can be as simple as:

declare var parse:any;

I wrote some guidance on the matter here : http://basarat.github.io/TypeScriptDeepDive/#/declarations

There is a huge resource of declaration files you can find at https://github.com/borisyankov/DefinitelyTyped . In particular check out FireBase : https://www.firebase.com/ and its declaration file : https://github.com/borisyankov/DefinitelyTyped/tree/master/firebase However there isn't one on parse.com yet which is why I mentioned the way to write your own.

Additionally you don't need a declaration file if you do not want any impressive static checking of the typescript code that interacts with the parse.com's api.

Upvotes: 1

Related Questions