How to use TypeScript for Web Package projects

It is possible to use TypeScript when writing code for components and services inside Web Package projects.

Step-by-step guide:

  1. Install https://github.com/palantir/eclipse-typescript TypeScript plugin into Servoy Developer

  2. In Solution Explorer, under "All web package projects", right-click the project you want to have TypeScript, and select "Configure" then "Enable TypeScript Builder"

  3. Change the extension of all your "js" files to "ts"

  4. Make sure your "ts" files are transpiled during project build, go to "Window", "Preferences", "TypeScript", "Compiler" and enable "Compile all TypeScript files on build"

  5. Include in your "ts" files the type definitons for Angularjs; you can download this from angular typings file, and include it in you project, then add the following line in your "ts" file, at the top : /// <reference path="../angularjs/angular.d.ts" />; make sure you set the correct path to the type definiton file

  6. If you are using other libraries, like jquery, you can try to find an already created type definition here https://github.com/DefinitelyTyped/DefinitelyTyped that you can include just like for Angularjs in the previous step

Last updated