...
https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html
TypeScript Configuration
The TypeScript configuration
The CLAPI TypeScript configuration file should be in the application CLientLogic/ directory, for example: sports-webui/ClientLogic/tsconfig.json
Note that you do not need to be familiar
For
For a list of tsconfig.json compiler options see the link below
https://www.typescriptlang.org/docs/handbook/compiler-options.html
Visual Studio Code
In the following examples we will be using Visual Studio Code.
...
https://code.visualstudio.com/docs/getstarted/introvideos
TSLint
Migrating to the CLAPI
In the following example we will migrate a function to the CLAPI. The function gets the foreign keys (or initial field values) when launching a window to create a new record.
...
Open the /sports-webui/ClientLogic/ folder in VS Code. Open Order/getOrderForeignKeys.js from the Explorer view (see picture below).
Start by renaming (F2) the file to getOrderForeignKeys.ts using the .ts TypeScript file extension.
Now that the file is saved as a TypeScript file, you canReplace
if (akioma.samples)
akioma.samples = {};akioma.samples.getOrderForeignKeys = function(self) {
With
namespace akioma.samples {
export function getOrderForeignKeys(self) {
Use namespaces to avoid naming conflicts. Note that functions must be exported to be used outside the namespace (namespaces are compiled into closures).
- Replace
self
witheventSource: akioma.swat.SwatObject
.
Note that the function parameter name does not have to be eventSource. For example: eventGrid eventForm, eventRibbon etc. Although self might be confusing with the JavaScript dynObject.
Note that the function parameter type does not have to be the generic base SwatObject as in this case. Use the correct Object Type class to avoid casting. - Replace
getObject("CustomerDetailsForm")
withgetForm("CustomerDetailsForm"),
getObject("CustomerGrid")
withgetGrid("CustomerGrid")
andcontainer
withwindow
.
The CLAPI supports generic traversing functions like getObject(), getLink() etc. which return the generic base SwatObject class object.
The CLAPI also supports type specific function like getForm(), getGrid(), getRibbon() etc. to avoid casting.
Alternatively you can use TypeScript casting. For example: (eventSource.getObject("MyForm") as akioma.swat.Form). - Replace
getValue
withgetDataValue
.
The Form and Grid classes have both a getScreenValue() and getDataValue() functions for getting the field screen value or record value respectively.
Save - Remember to save (Ctrl-S) and rename (F2) the file as Order/getOrderForeignKeys.ts using the .ts TypeScript file extension (see picture below)your work.
Documentation
In addition to the intellisense of the class methods, properties and their explanations
...