TypeScript support for Cloud Code

Hello, dear support!

I’m trying to understand if I can use TS in my Cloud Code project locally. I’d prefer to develop using TS instead of raw JS.
I didn’t find the native support for Node.js TS at the moment.
My idea is to implement a Gulp task to translate the source TS code to JS before code-runner execution and deployment.
The main issue is to save JS Docs, that the system generate and avoid manually copy paste process.

Do you have any other suggestions/advices to solve the case?

Thanks in advance!

yes, you can use TS. I will add example of usage in a few days and I respond to you when it will be ready

Hello, sounds great! I think we almost solved the case on our end, but we waiting for your example as well. Additionally, we are thinking to implement a debug watcher to translate TS and deploy the code (vby code-runner) while developing.
Also, we noticed minor issue, that static method usage leads to an exception. The assumption is you call new MyService().myFunction() under the hood. It is not a critical, perhaps TS/IDE should be configured to not suggest static functions.
Thank you!

Hello @Boris_Velvetech

Here is a sample project with TS, the main idea is to compile TS into JS and then publish

  1. run npm i to install all the deps
  2. replace “app.id” and “app.apiKey” values in the coderunner.json with your own
  3. run npm run build to compile
  4. run npm run deploy

TS_default_coding.zip (36.3 KB)

Regards, Vlad

Hi @Boris_Velvetech,

You also can check todo project that I created on github GitHub - mrskofild/backendless-typescript-example.

Hello, @Yuri_Yefimovich and @vladimir-upirov,
Thank you for the updates!
We will review your examples in a few days and will try to give feedback.

Have a great day.

Hello, dear support!

We reviewed your example.
First of all, we’d like to thank you for your efforts. It can be a good starting point for the teams.
Unfortunately, we didn’t find the way of managing JSdocs automatically, extended model typings, debug watcher in your solution. But we have implemented those things in our project already. The last not convenient things we have are:

  1. Debugging process. We can set breakpoints in the generated JS files, but not in the original source code like common TS server-side project works. I guess it is not a solvable task since Backendless knows nothing about the TS files.
  2. Lack of typed ORM for the DB queries. We are on the current step and implementing wrapper for the query builder available in the stock SDK.

Again, thank you very much!

1 Like

Hello @Boris_Velvetech

In my example there is settings for debugger in vscode that allow to debug this example. .vscode/launch.json. Also there is example of static method usage/implementation, for example is isExist. Let me know if you have any questions

1 Like