Giter VIP home page Giter VIP logo

Comments (4)

kevinbarabash avatar kevinbarabash commented on June 10, 2024

I think this is an issue with the babel plugins/presets I have configured. I'm trying to make my setup match the setup used in the tests.

from babel-plugin-flow-react-proptypes.

kevinbarabash avatar kevinbarabash commented on June 10, 2024

It turns out it wasn't a configuration issue, but rather an issue when there are multiple components in the same file while using imported types. I'll try to create a minimal reproducible test case, but in the meantime I should be able to work around this by splitting the components into separate files.

from babel-plugin-flow-react-proptypes.

kevinbarabash avatar kevinbarabash commented on June 10, 2024

Splitting up the files did indeed solve the issue.

from babel-plugin-flow-react-proptypes.

kevinbarabash avatar kevinbarabash commented on June 10, 2024

Disabling the @babel/env preset in the test outputs the following code which has no undefined variables:

// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`import-object 1`] = `
"function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

import PropTypes from \\"prop-types\\";
import { bpfrpt_proptype_RowProps } from \\"./other-row.jsx\\";
import * as React from \\"react\\";

class TableOfContentsRow extends React.Component {
  render() {
    return React.createElement(\\"div\\", null, \\"I'm a row\\");
  }

}

_defineProperty(TableOfContentsRow, \\"propTypes\\", Object.assign({}, bpfrpt_proptype_RowProps === PropTypes.any ? {} : bpfrpt_proptype_RowProps, {
  domain: PropTypes.string.isRequired
}));

export default class TableOfContentsRowWithQuery extends React.Component {
  render() {
    return React.createElement(TableOfContentsRow, null);
  }

}

_defineProperty(TableOfContentsRowWithQuery, \\"propTypes\\", Object.assign({}, bpfrpt_proptype_RowProps === PropTypes.any ? {} : bpfrpt_proptype_RowProps, {
  domain: PropTypes.string.isRequired
}));"
`;

I tried pasting this into the babeljs.io repl and turned on @babel/env and it does the right thing. There must be some subtle interaction when @babel/env is run on the modified AST chunks that this plugin generates.

from babel-plugin-flow-react-proptypes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.