Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't import { [MY_VAR]: 'wegwegweg' } #476

Closed
ivangeorgiew opened this issue Dec 1, 2017 · 3 comments
Closed

Doesn't import { [MY_VAR]: 'wegwegweg' } #476

ivangeorgiew opened this issue Dec 1, 2017 · 3 comments

Comments

@ivangeorgiew
Copy link
Contributor

When running the fix imports command, variables that are noted as keys in objects like so are not imported:

const bla = {
  [MY_VAR]: 'gegwg'
}

I tried logging all the nodes inside the function normalizeNode and it is shown that:
node.name is MY_VAR, context.key is key, context.parent is ObjectProperty.

Then I tried the same logging for:

const bla = {
  [MY_VAR]: 'gegwg',
  myVar: 'fwegweg',
  'myVar': 'fwegwegh' 
}

And saw that there is no difference between them in the logged information, so I can't make an if/else statement inside function normalizeNode.

Can you fix that or tell how to fix it myself?
Thanks in advance.

@trotzig
Copy link
Collaborator

trotzig commented Dec 1, 2017

Wow, good catch! Thanks! These bugs can usually be solved pretty quickly with a test-driven approach (`findUndefinedIdentifiers-test.jsx), but knowing how tricky this bit of code is it's probably easiest for me to address. I'll push something soon.

@trotzig trotzig closed this as completed in 2f1ced7 Dec 1, 2017
@ivangeorgiew
Copy link
Contributor Author

Thanks, its working now. However I found other bugs with fixImports:
Here MY_VAR isn't imported.

const bla = {
  keyName: obj[MY_VAR]
}

Desctructured aliases are imported, but they shouldn't be:
myAlias shouldn't be imported.

const { prop: myAlias } = obj

@trotzig
Copy link
Collaborator

trotzig commented Dec 5, 2017

Good catch! I've moved the new issues into a new ticket so that we can follow up better: #480

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants