What is the difference between xtype and alias used in Sencha? They're both seem to be used as shorthand in different places.
2 Answers
When you use "alias" to declare an xtype, you have to preface it with "widget".
Example:
{
...
alias: 'widget.mycomponent'
...
}
When you use the xtype property, you can leave the "widget." part off, because that part is assumed:
Example:
{
...
xtype: 'mycomponent'
...
}
The reason for the two different properties is because you can declare aliases of things other than "widget", like alias: 'layout.card', which is used in the framework. However, for end-user code that reference view objects, you'll probably be using either
alias: 'widget.mycomponent'
or
xtype: 'mycomponent'

- 1,513
- 14
- 15
This is really confusing, even Sencha Touch developers team does not have a common opinion.
As far as I know, they design this merely for performance. Alias
appears earlier than xtype
, they create xtype
config because if we don't have to parse the string to get the xtype like before, it's faster.
Anyway, things like xtype
, ptype
, ltype
or most common, alias
should be unified and clarified in next releases, said the dev team.

- 6,345
- 7
- 30
- 50
-
Looks like they did not :( – Fawar Jul 09 '13 at 14:46
-
2I used to work for Sencha, I can assure you that the Sencha Touch team has never said this. The difference between alias and xtype is quite clear, and is reflected in the documentation. – Patrick Chu May 02 '14 at 16:18
-
1it's been long since this answer was posted. I didn't even remember which thread I joined on sencha forum, but it MIGHT be this one: http://www.sencha.com/forum/showthread.php?150577-Ext.define-xtype-vs-alias – Thiem Nguyen May 02 '14 at 16:49