I'm trying to create a Lightning Component and there is a Custom Apex Controller class with a child class in it.

But I'm receiving an error like this:

Failed to save undefined: No TYPE named apex://MyAccountController.wChildItem[] found : [markup://vctm:AccCtrl]: Source

The code for my Lightning Component looks like this:

Code for .cmp file:

<aura:component controller="MyAccountController">
    <!-- Attributes -->
    <aura:attribute name="children" type="MyAccountController.wChildItem[]" />

Code for APEX Class:

public with sharing class MyAccountController {

    public  static  wChildItem[]    findRecords() {
        List<wChildItem> items  = new List<wChildItem>();
        return items;

    public class wChildItem {
        public  string  sname   { get;set; }

        public  string  stype   { get;set; }

        public wChildItem(string n, string t) {
            sname   = n;
            stype       = t;

Why do I keep getting the no TYPE cannot be found error on save? What is a workaround for this error?

  • 1
    can you check whether your class exist or not from setup->apex class because above code working for me. – Himanshu Nov 25 '15 at 13:15
  • Yes the class exists. Its compiled as well and is Valid and active as well. – VarunC Nov 25 '15 at 13:18
  • @VarunC What version are you using ?What is the tool you are using ?I mean eclipse .mavens or force.com UI – Mohith Shrivastava Nov 25 '15 at 13:25
  • I'm using Developer Console, and the API version of Lightning Component and Apex class both is 35.0 – VarunC Nov 25 '15 at 13:31
  • @VarunC have you checked class existence from developer console or Apex Class section? – Himanshu Nov 25 '15 at 13:56

Visualforce Components have a problem where they can't have attributes that reference an inner class as their type. You might be seeing something similar with your Lightning Component.

See this question: Reference inner class in Visualforce component

Try breaking wChildItem out into its own class.

You also may need to use your namespace when referencing your inner class, if you didn't pick a namespace, your namespace is likely "c".


<aura:attribute name="children" type="c.wChildItem[]" />

  • Actually I've already tried that as well. With that the issue I've is, i couldn't use List/Array of items as Attribute in Lightning Component. I try to save the code this way <aura:attribute name="children" type="wChildItem[]" /> but after save it revert automatically back to this <aura:attribute name="children" type="wChildItem" /> - noticed the saved version is not a List of wChildItem but becomes a singular item. – VarunC Nov 25 '15 at 14:15
  • 1
    You'll need to use your namespace, which might just be "c". See this link: developer.salesforce.com/docs/atlas.en-us.lightning.meta/…. So try <aura:attribute name="children" type="c.wChildItem[]" /> – frontendloader Nov 25 '15 at 14:23
  • Thanks ... That worked. Silly me, don't know how I missed that part of the documentation :-( ... I would suggest adding the document link from your comments to your Answer above, as that is necessary for making it a complete answer ... – VarunC Nov 25 '15 at 14:38
  • 1
    Hey @frontendloader - I'm back with same issue again. I tried using this same code but now with a Namespace of my organization <aura:attribute name="children" type="myns.wChildItem[]" /> and it auto reverts back to <aura:attribute name="children" type="myns.wChildItem" /> a singular item instead of datatype being an Array. Can you tell me why it is doing that? It works fine if i replace my namespace with c. – VarunC Dec 4 '15 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.