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.
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 |
Stored procedure a2v10.[Agent.Load]
.
The procedure returns one TAgent
type record with
the fields Id
, Name
, Code
.
model.json
file, the presence of the checkTypes
item is checked. If it is not there, nothing is executed.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.
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
.