1. #11
    Sencha Premium Member
    Join Date
    Dec 2011
    Posts
    4
    Vote Rating
    1
    slavah is on a distinguished road

      0  

    Default


    HI, Good question.
    Was playing today with TypeScript. Really like how unobtrusive it is.
    You can use it whenever you like to, does not to my experience screw up your code.
    Moved our 6k+ loc Jasmine test to it.

    But real problem starts when start mixing TypeScript with ExtJS and with real production code, where you have structural types.

    Example I came up with (would love to see your usages as well)

    Code:
    Ext.define('WebApp.model.RenderableRecord', {
        extend: 'Ext.data.Model',
        idPropert: 'id',
    
        isRenderableRecord : true,
    
        fields: [
            { name: 'id', type: 'string' },
            { name: 'name', type: 'string' },
            {
                name: 'renderable',
                convert: function (val, model) {return val;}
            },
        ],
        
        renderItems: function (renderer: Function) {
            var me = this;
            return function (config: Object) {
                renderer(me.get('renderable'), config);
            }
        },
    
    });
    
    interface View  {
        render(renderTo: string): void;
    }
    
    interface Renderable {
        rendrer(itemToRender: Object, config: Object) : View;
    }
    
    interface RenderableRecord {
        get(val: string): any;
        isRenderableRecord: bool;
        renderItems(val: Function):(config: Object) => View;
    }
    
    var record = <RenderableRecord> Ext.create('WebApp.model.RenderableRecord');
    var renderable = <Renderable> record.get('renderable');
    var view = record.renderItems(renderable.rendrer.bind(renderable));

    Would love to have structural typing or pattern matching.
    Code:
    get(val: 'id'): string;
    get(val: 'renderable'): Renderable  // but that probably would cause more issues with ExtJS?
    get(val:string): any
    get(val: any): throw Error // in case all of the above patterns exhausted and we got called with some bogus data
    What's your usages, patterns, ideas?

  2. #12
    Sencha Premium Member
    Join Date
    Mar 2009
    Posts
    34
    Vote Rating
    -13
    Dhugal can only hope to improve

      4  

    Default


    I have to say I find this dismissive response from a Sencha representative disappointing.

    I agree with Javascript magic that the eclipse option is not very appealing for those of us using the visual studio toolset.

    I develop both the back end and front end in VS and having to have another IDE just to get intellisense etc. in the javascript is not ideal.

    I think Sencha maybe missing a trick here because there is a large market of VS developers out there who are spoilt with tooling and working with external products such as Ext can be painful in comparison. Typescript potentially provides Sencha with a good means to target that market and reduce the learning curve those with less experience in Javascript frameworks.

    I have built a large application using Ext 3.4 and coming from a primarily a desktop application development background it took a while to get my head around Ext Js, anything that makes this easier could result in more license sales.

    This is especially important when you have various drag and drop tool kits for ASP.NET which allows users to get something up and running literally in a few clicks. (I realise the end result is generally not very good but the point is that you need to provide a comparable getting started experience).

  3. #13
    Sencha Premium Member
    Join Date
    Apr 2011
    Location
    Chicago, IL
    Posts
    65
    Vote Rating
    11
    ccg will become famous soon enough

      0  

    Default Low-hanging fruit

    Low-hanging fruit


    I haven't a chance yet to try it (I'm hoping to take a crack at it over the weekend), but I've kept this in the back of my mind.

    I think a quick win would be to produce declarations for all the objects and functions that appear as literals in our client code. For example, it looks like it would be pretty straightforward to say that Ext.ModelMgr is an object with a method called getModel() that takes a string parameter.

    I suspect the problem is going to be user-defined classes, because, with the Ext JS 4 class system, our custom classes rarely appear as literals in our code (MyClass) but only as quoted strings ("MyClass"). We don't write new MyClass(foo, bar);, we say Ext.create("MyClass", {...});. That means that the tools would have to parse the strings to figure out what fields are available on the config object that is passed in.

    Similarly, I think xtypes will be a problem. TypeScript has structural typing, but I'm guessing there's not enough information in a lot of the config object literals that we pass around to determine the type unambiguously. Many of the config parameters have default values, so we only pass in the fields we're overriding.

    Contrived example, but if I pass in the following child-object config while instantiating a Sencha view object...

    Code:
    {
      xtype: '...',
      height: 100,
      width: 100
    }
    ... without parsing the 'xtype' field, there's not enough information in that object literal to determine if I want to create a Container, or a Button, or whatever, so structural typing won't help.

    But I think there is some low-hanging fruit. We can create a .d.ts file for a big chunk of the Ext.* namespace.
    Last edited by ccg; 5 Oct 2012 at 8:53 AM. Reason: typo

  4. #14
    Sencha Premium Member
    Join Date
    Dec 2009
    Location
    Rhode Island
    Posts
    231
    Vote Rating
    24
    dmulcahey will become famous soon enough dmulcahey will become famous soon enough

      0  

    Default


    I haven't looked too much at typescript yet but I figured I would throw this out there... There is an awful lot of metadata that describes the properties and functions in the commented versions of ExtJs for JsDuck. I'm not positive but it may contain the necesary data to create at least a good start for typescript bindings... Someone would just have to parse the data and spit it out in the correct format...

  5. #15
    Sencha Premium Member
    Join Date
    Sep 2012
    Posts
    94
    Vote Rating
    8
    zz9pa is on a distinguished road

      0  

    Default


    As I said - I'm got some C# that parses this meta data - so we could use that as a starting point...

    If anyone is interested - I can upload what I've got somewhere....

  6. #16
    Sencha Premium Member
    Join Date
    Apr 2011
    Location
    Chicago, IL
    Posts
    65
    Vote Rating
    11
    ccg will become famous soon enough

      0  

    Default GitHub or BitBucket

    GitHub or BitBucket


    @zz9pa, can you put your code on a public repository somewhere, like GitHub or BitBucket? I'm not a C# developer, but I'd like to take a look at what you've already done. Thanks!

  7. #17
    Sencha Premium Member
    Join Date
    Mar 2009
    Posts
    34
    Vote Rating
    -13
    Dhugal can only hope to improve

      1  

    Default


    Quote Originally Posted by ccg View Post
    @zz9pa, can you put your code on a public repository somewhere, like GitHub or BitBucket? I'm not a C# developer, but I'd like to take a look at what you've already done. Thanks!
    Ditto - I would also like to take a look (and I develop in c# so, time permitting, I may be able to add some input).

  8. #18
    Sencha Premium Member
    Join Date
    Jul 2011
    Posts
    119
    Vote Rating
    5
    john76543 is on a distinguished road

      0  

    Default


    Just like to add my +1 to supporting TypeScript (providing definition files for ExtJS). For everyone who doesn't have the entire ExtJS API in their head at all times, TypeScript could be a life saver in productivity. It certainly blows away JSHint.

    Sencha supports GWT so it makes a lot of sense for them to support TS too. I'd expect TS to be more widespread than GWT in a few years. After all, it's just a lighter-weight solution to the same problem.

  9. #19
    Sencha Premium Member
    Join Date
    Sep 2012
    Posts
    94
    Vote Rating
    8
    zz9pa is on a distinguished road

      0  

    Default


    I created a github repo.
    Tried posting twice already - so here goes #3

    github.com/zz9pa/extjsTypescript/
    Last edited by zz9pa; 8 Oct 2012 at 2:31 AM. Reason: Include url

  10. #20
    Ext JS Premium Member
    Join Date
    Feb 2008
    Posts
    2
    Vote Rating
    3
    mlp is on a distinguished road

      1  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    Or you can write correct and productive JavaScript without the need of any compiler like coffeescript or typescript.
    Sorry, but as a paying customer I find your attitude seriously lacking. The question you guys at Sencha should ask yourself is: Can we use TypeScript to benefit your customers and if yes, is the effort worth the result.

    I really think at least for your customers that use Visual Studio 2012, providing TypeScript definition files would give your customers a much better tooling experience with little effort and create an additional selling point.