GithubHelp home page GithubHelp logo

ext-typescript-generator's Introduction

ExtJS TypeScript Definition Generator

Note: These definitions are now available in the DefinitelyTyped repository.

Quick (Temporary) Initial Notes

  • Untyped and fully typed definition files are available in the /definition folder, BUT...
  • You almost certainly just want the "-Interfaces" definition, since creating real classes and using them isn't an option (see below)
  • Add a reference to the definition at the top of your .ts file.
  • Cast configuration blocks to the appropriate interface to enable code hinting.
  • If you want to try running this with your own JSDuck output, check build.gradle file's ConfigGroups, and place the JSON files in the appropriate location.

Update

  • After a LOT of trial and error, it looks like casting objects to Ext JS interfaces is the only option. Trying to create concrete TypeScript classes that extend concrete Ext JS classes causes myriad conflicts between the modules, classes, extends, and super code generated by the TS compiler and the Ext JS class system. :-/
  • Not ideal, but it still maintains code hinting/insight and type checking, which are the two most important things.
  • The example below has been updated to show this approach.

Example: CompanyGridPanel.ts:

/// <reference path="./definitions/ExtJS-4.2.1-Typed-Interfaces.d.ts" />

Ext.define("CompanyGridPanel", <Ext.grid.IPanel>{
    extend: "Ext.grid.Panel",
    alias: "widget.companyGridPanel",

    config: {
        companyStore: null
    },

    initComponent: function () {
        Ext.applyIf(this, {
            itemId: "companyGridPanel",
            title: "Company Listing",
            store: this.companyStore,
            columnLines: true,
            
            columns: [
              <Ext.grid.column.IColumn>{
                  xtype: "gridcolumn",
                  dataIndex: "company",
                  text: "Company",
                  flex: 1
              }, <Ext.grid.column.INumber>{
                  xtype: "numbercolumn",
                  dataIndex: "price",
                  text: "Price",
                  renderer: Ext.util.Format.usMoney
              }, <Ext.grid.column.INumber>{
                  xtype: "numbercolumn",
                  dataIndex: "change",
                  text: "Change",
                  format: "0.00"
              }, <Ext.grid.column.INumber>{
                  xtype: "numbercolumn",
                  dataIndex: "pctChange",
                  text: "% Change",
                  format: "0.00"
              }, <Ext.grid.column.IDate>{
                  xtype: "datecolumn",
                  dataIndex: "lastChange",
                  text: "Last Change"
              }, <Ext.grid.column.IColumn>{
                  xtype: "gridcolumn",
                  dataIndex: "industry",
                  text: "Industry"
              }
            ],

            tbar: [
              {
                  xtype: "checkbox",
                  itemId: "manufacturingFilter",
                  boxLabel: "Show only Manufacturing companies"
              }
            ]
        });

        return this.callParent(arguments);
    }
});

ext-typescript-generator's People

Contributors

brian428 avatar stokito avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.