Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

TypeScript is a superset of JavaScript which adds optional typing and compiles into plain JavaScript.

JavaScript code is also valid TypeScript code (although it depends on the compiler settings).

TypeScript allows for compile-time checking of types, identifiers etc. and even while typing code in your editor.

TypeScript also allows for intellisense on class methods and properties together with JSDoc.

For an introduction to TypeScript see the link below -

https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html

Installing TypeScript

TypeScript comes pre-installed and setup with the AKIOMA framework. To verify that TypeScript is installed -

From the command line, go to the "swat-webui/akioma/sass" directory and type "npm list typescript".

If an empty list is shown, type "npm install" to install the missing TypeScript package.

TypeScript Configuration

The tsconfig.json is the TypeScript configuration file placed at the project root directory.

The TypeScript SDK tsconfig.json is in the "swat-webui/akioma/ts" directory.

The TypeScript client logic tsconfig.json for the Sports demo application is in the "sports-webui/ClientLogic" directory.

For more information on the TypeScript configuration options see the link below -

https://www.typescriptlang.org/docs/handbook/compiler-options.html

Compiling TypeScript

The TypeScript compiler is part of the regular AKIOMA build scripts. For example -

When running the AKIOMA build script with "npm run akioma" the TypeScript SDK is compiled and added to the application.

When running the Sports demo build script with "npm run sports" the TypeScript client logic is compiled and added to the application.

Visual Studio Code

Visual Studio Code is a popular, free code editor from Microsoft with TypeScript support.

To install VS Code follow the link below -

https://code.visualstudio.com/docs/?dv=win

For introductory videos on VS Code see the link below -

https://code.visualstudio.com/docs/getstarted/introvideos

Calling TypeScript Functions

TypeScript functions calls from event handlers in the visual designer or SCL maintenance (starting with the "$" sign) look just like JavaScript function calls

the only difference is that they must pass the "eventSource" object instead of the "self" object.

Writing TypeScript Functions

Place the client logic TypeScript files in the "ClientLogic" directory just like the JavaScript files.

Remember that the TypeScript file extension is ".ts" instead of the JavaScript ".js".

For example look at the "onCustomerSalesrepValueChanged.ts" in the "sports-webui/ClientLogic" directory.

 

 

  • No labels