Implicit operators

Topics: General, Language Specification
Nov 18, 2012 at 8:04 PM
Edited Nov 18, 2012 at 8:18 PM

In some classes configuration we often allow configure properties with multiple signatures:


new Ext.Panel({

tbar : new Ext.Toolbar({

items : [{text : 'save'}, {text : 'cancel'}]





new Ext.Panel({

tbar : [{text : 'save'}, {text : 'cancel'}]



It would be really nice if we had, only in compile time, a feature like C# implicit operator.

This pattern is used in scriptsharp.


so instead of declaring type any


class Panel { 
    public tbar: any;



we could create a class to inform what types we can convert

class Panel { 
    public tbar: TbarConfig;

class TbarConfig { 
    implicit operator Ext.Toolbar(items : any);
    implicit operator Ext.Toolbar(items : Ext.Toobar);






Nov 20, 2012 at 4:05 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.