vscode-glean: Error message clarification: 'You must pass a scope and parentPath'

Hi I am getting the following error when trying to convert a react PureComponent to stateless.

You must pass a scope and parentPath unless traversing a Program/File. Instead of that you tried to traverse a Identifier node without passing scope and parentPath.

Sorry if this is not the right place, but I am confused and cannot find an answer anywhere.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 21 (11 by maintainers)

Commits related to this issue

Most upvoted comments

@Arelav. Thanks for reporting. Can you try to create a minimal usecase?

So the minimal example does work without experiment and doesn’t when the experiment is on.

import React from 'react';

interface Props {
  text: string;
}

class MyComponent extends React.PureComponent<Props> {
  render() {
    const { text } = this.props;

    return <>Test {text}</>;
  }
}

export default MyComponent;

Looks like props destructuring is an issue here.

Because this works fine in both cases.

class MyComponent extends React.PureComponent<Props> {
  render() {
    return <>Test {this.props.text}</>;
  }
}

Hello! I’m using 5.1.1 and I still see the issue when trying to refactor this:

type Props = { content: Content };

export default class BannerItem extends React.PureComponent<Props> {
  contentDidSelect = () => {
    NavigationService.navigateToContent(this.props.content);
  };

  render() {
    return (
      <TouchableOpacity
        activeOpacity={1}
        style={styles.slideInnerContainer}
        onPress={this.contentDidSelect}>
        <View style={[styles.imageContainer, mainStyles.imageContainerShadow]}>
          <Image
            source={{ uri: this.props.content.image.en }}
            style={styles.image}
          />
        </View>
      </TouchableOpacity>
    );
  }
}

Seems like there’s the same issue whenever you try to spread this.props in JSX too:

class MyComponent extends React.PureComponent<Record<string, unknown>, {}> {
    render() {
        return (
            <OtherComponent {...this.props} />
        );
    }
}

gives the same error