Wednesday, 20 February 2019

Babel plugins - Member access with index

I am writing a babel plugin. I came across a place where I need to use index operator. This is code I want to get a[Symbol.something](b), however, I can't seem to find a way to do it. I have tried doing something like this:

types.callExpression(
    types.memberExpression(types.Identifier('a'), 
        types.memberExpression(types.Identifier('Symbol'), types.Identifier('something'))
    ),
    [types.Identifier('b')]
)

However, it throws error TypeError: Property property of MemberExpression expected node to be of a type ["Identifier","PrivateName"] but instead g ot "MemberExpression". I googled my problem, but I can't seem to find a way to do it.



from Babel plugins - Member access with index

No comments:

Post a Comment