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'}]
})
}):
or
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.
http://msdn.microsoft.com/en-us/library/z5z9kes2(v=vs.100).aspx
http://extsharp.codeplex.com/SourceControl/changeset/view/94877#1716706
http://extsharp.codeplex.com/SourceControl/changeset/view/94877#1716724
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);
}
|