Minify: babel-plugin-transform-property-literals breaks 0 padded property names

Created on 8 Mar 2017  路  3Comments  路  Source: babel/minify

I have an api that gives me an object like this:

data = {
  "00": { ... },
  "01": { ... },
  "02": { ... }
  `...`
}

When accessing data["00"] babili convets it to data[0] breaking the code.

bug has PR

All 3 comments

Hey @GabbeV! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

You can use

properties: {
  memberExpression: false,
  propertyLiterals: false,
}

as your babili options

or you can pass

properties: false

in your options.

Thank you @boopathi, that works great for a temporary fix. I would still consider it a bug though as it should be avoidable by checking if the numeric strings are 0 padded.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Gustorn picture Gustorn  路  4Comments

boopathi picture boopathi  路  3Comments

kristianmandrup picture kristianmandrup  路  6Comments

jacobmischka picture jacobmischka  路  5Comments

jamesloewen picture jamesloewen  路  3Comments