Symbol is not defined


#1

Hello,

I have this code in server part :

 var QueryBuilderInstance = null;
class QueryBuilder {
    constructor() {
    }
    static getInstance() {
        if (QueryBuilderInstance == null)
            QueryBuilderInstance = new QueryBuilder();
        return QueryBuilderInstance;
    }
    buildQuery(templateQuery, params) {
        if(params != null && params.size > 0) {
            console.log(params.entries());

            for (let [key, value] of params.entries()) {
                templateQuery[key] = value;
            }
        }
        console.log(templateQuery);
        return templateQuery;
    }
}
this.QueryBuilder = QueryBuilder;

When I run this code I have this error : ReferenceError: Symbol is not defined,
This error is for the line with the loop for…of, I don’t understand why ?

Thanks,
GJean


#2

The for ... of ... is transpiled to include a reference to Symbol: https://www.youtube.com/watch?v=05Z6YGiZKmE&feature=youtu.be&t=1130

As to why you’re getting an error, I don’t really know … has the es5-shim package been added?


#3

es5-shim is already present in my package


#4

I solve problem to replace for…of by forEach()


#5

Using https://atmospherejs.com/xolvio/core-js would also fix the problem I guess. It adds a Symbol polyfill. This polyfill will be shipped with the next Meteor release by default.