[SalesForce] Lightning Components: Which type of parameters are supported in @AuraEnabled Apex methods

Assume we have this code in the controller or helper to invoke a APEX method:

action = cmp.get("c.TestUwe");
action.setParams( { params :  ['777','888'] } );
action.setCallback( null, function(callbackResult) {
    if(callbackResult.getState()=='SUCCESS') {
        var result = callbackResult.getReturnValue();
        console.log('RESULT', result  );
    }
    if(callbackResult.getState()=='ERROR') {
        console.log('ERROR', callbackResult.getError() ); 
    }
});
$A.enqueueAction( action );

In Apex we have one input param of List<Object>:

@AuraEnabled public static Object TestUwe(List<Object> params) {
    system.debug( params );
    return null;
}   

All good: this works fine!

Now if I change the type to just Object

@AuraEnabled public static Object TestUwe(Object params) 

It does not work anymore:

An internal server error has occurred↵Error ID: 1556564141-71620
(-2109904195)↵↵org.auraframework.throwable.AuraExecutionException:
apex://elfLC_WorkOrderLineItemEditor:
java.lang.UnsupportedOperationException↵ at …

Other example is: we keep List<Object> in APEX but provide this as params:

action.setParams( { params :  ['777','888', { test : 'abc' }] } );

An internal server error has occurred↵Error ID: 1556564141-71801
(119852647)↵↵org.auraframework.throwable.AuraExecutionException:
apex://elfLC_WorkOrderLineItemEditor:
common.apex.runtime.impl.ExecutionException: Salesforce System Error:
1556564141-71800 (-1664928234) (-1664928234)↵ at …

So not all possible types works as expected.

I've read these chapters but can't find any documentation on which types are supported and which not. Where does Salesforce specify EXACTLY what is allowed and what not?

I found some posts where people serialize the parameters, e.g.:

Why is this necessary at all? Why can't the framework just do the serialization of anything on it's own and in APEX we just use the typeless Object and take care on proper handling from there dynamically?

But the main question is:

Where do I find the official documentation on which types are allowed and which are forbidden? It should be stated at a prominent place here in order to save us a lot of trial-and-error time.

Best Answer

From my experience, the best practice for passing parameter from Lightning component to Apex class is to use JSON.stringify() on anything that is more complicated than single string (every list, map, object, map of lists, ...). You can then deserialize/parse it in apex, which is safer then managing it in javascript.