Typescript Code Generator - Zontroy

Typescript Code Generator

How to generate typescript code with Zontroy

Typescript is getting more popular every day. If you are a typescript developer you should think about using a Typescript Code generator. Because robotic tasks are nightmares for a developer while writing typescript code as in other scripting languages.

On this article we are going to begin code generation for typescript. The diagram provided below includes a sample and easy database model just to start. You can apply the method provided in this article to your own database model and project.

Zontroy is very flexible to use with any type of software project and well-known databases. Also you can generate typescript code according to your entity classes. Generating typescript is very simple and productive.

After design our data model, we need a typescript template code file. Template code files are input for Zontroy to generate code files and lines. There are 3 type of template file:

Zontroy Repeating File (zref) : This template file generates one file for each entity in data model.

Zontroy Repeating File

Zontroy Single File (zsif) : This template file generates one single file for all entities in data model.

Zontroy Single File

Zontroy Inner Repeating File (ziref) : This template file generates a directory and a file for each entity in data model.

Zontroy Inner Repeating File

After this brief explanation about Zontroy template file types, we can create a Zontroy Project.

Download Zontroy Free using this link and after installation click File -> New Project -> Create (Empty Zontroy Project)

After clicking Create button you will see your entities in Entity Window.

In Project Window, there will be just Zontroy Project file.

Right click on typescript folder and click Add File.

In the New File form, select Zontroy Repeating File and give a name like below.

This file name means create code file for each entity and name it same as entity name. Open the file created and write following template codes to generate typescript code files.

class [[[zg-entity...zg-name]]] {
    [[[zg-item...zg-name]]]: [[[zg-item...zg-targetType]]];}}}
    constructor(zg-for(((zg-item:::[[[zg-entity...zg-fields]]]))){{{[[[zg-item...zg-name]]]: [[[zg-item...zg-targetType]]],}}} ) {
        this.[[[zg-item...zg-name]]] = [[[zg-item...zg-targetType]]];}}}

After that click Generate button on the top and get created code files below.

Generated code files will be as following:

class country {
    country_id: number;
    country: string;
    last_update: Date;
    constructor(country_id: number,country: string,last_update: Date, ) {
        this.country_id = number;
        this.country = string;
        this.last_update = Date;

This is just a begining to Zontroy Generator. You can generate dozens of any kind of code files in a few minutes like this after preparing templates. You can create template files in order to meet your coding needs. Also you can go official typescript website to find more examples and generate them in Zontroy.

Post a Comment