ngAnnotate - Warning: StringMap expected string key
I also faced the same problem but in my case, there was a different issue.
One of our team members has initialized function parameter to some default value. Something like the following.
$scope.functionName = function(defaultVar = false){
//some code
}
and in my gulp script, there was a line
.pipe(plugins.if(release, plugins.ngAnnotate()))
So when I have removed this line the build script automatically printed the error in console pointing to the exact file and line number where the error was.
Finally, I was able to solve it by removing that variable initialization code.
Hope this will help someone...
The issue turned out to be use of ES6 notation, in this case arrow functions (=>), default parameters and let.
I haven't looked in detail as to why ngAnnotate doesn't support this.
To find where the issues were I overrode the ngAnnotate warning with grunt switch --force and later in the build uglify complained about the ES6 syntax with more detail.
Possible reasons:
() => {}
{ value }
let
function (...args)
function (defaultVar = false)
Solutions:
function () {}
{ value: value }
var
function (args)
function (defaultVar) { defaultVar = (defaultVar === undefined) ? false : defaultVar }