wix-incubator / vscode-glean

The extension provides refactoring tools for your React codebase
MIT License
1.46k stars 56 forks source link

Quoted string literals as object keys break 'Extract Component to File' #63

Open will-ks opened 5 years ago

will-ks commented 5 years ago

Great plugin! Found an issue- when trying to use the 'Extract component to file' function, if the selected component has a property using an object property accessed via a quoted string literal, it fails with Property name expected type of string but got null

Eg. This works:

import { Card } from 'antd';
import React from 'react';

export default () => {
  const foo = {
    bar: 'foo',
  };
  return (
    <Card title={foo.bar}>
      <h1>foo</h1>
    </Card>
  );
};

But this fails:

import { Card } from 'antd';
import React from 'react';

export default () => {
  const foo = {
    bar: 'foo',
  };
  return (
    <Card title={foo['bar']}>
      <h1>foo</h1>
    </Card>
  );
};
borislit commented 5 years ago

@dambusm hey! Glad you like it! Nice catch! Ill have a look at this ASAP, although PR is super welcome! Should be an easy fix