A2v10 Platform documentation
UK


Types Checking

The system provides the ability to dynamically (at runtime) type conformance checking. The conformity of the types and properties obtained from the model and described in the *.d.ts definition file is checked. In addition, when rendering xaml-views, the correspondence of the bindings to the specified types is checked.

Thus, when type checking is enabled, the system guarantees that the model retrieved from the database matches the description and that only existing bindings are used in the view. The TypeScript compiler takes care of data and template code compliance.

This mechanism will only work if templates are written in TypeScript.

Example

Suppose, for example, we use type checking when editing properties of a contractor. This part of the application is located in the /catalog/agent folder.

Files in the folder:

File Description
model.json model description file
model.d.ts type definition file
edit.template.ts template file (TypeScript)
edit.dialog.xaml view file

file model.json


Model content

Stored procedure a2v10.[Agent.Load].


The procedure returns one TAgent type record with the fields Id, Name, Code.

model.d.ts

	

edit.template.ts file fragment

	

How it works

  • The model is loaded from the database and the metadata is built.
  • In the model.json file, the presence of the checkTypes item is checked. If it is not there, nothing is executed.
  • If a data description file is specified, then it is loaded and all types described in it are parsed.
  • The conformity of the types described in the model.d.ts иfile and the types obtained from the data model is checked. The type names and their properties must match. Property names that start with the "$" character are considered computed and are not checked in the data model. They will be needed in the next step. If mismatches are found, an exception is thrown.
  • While rendering the view, all bindings are checked. Upon an attempt to bind to a property that does not exist, an exception is thrown.

Please note!. Dynamic type checking will only work in a debug configuration.
The configuration property in the appSettings section of the Web.config file must be set to debug.