-
Notifications
You must be signed in to change notification settings - Fork 49
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
babelPluginFlowReactPropTypes_proptype_Element is not defined #115
Comments
It seems like we are missing a declaration or require for Here is the entire build file for that: "use strict";
/**
* return type of ReactDOM.findDOMNode()
*
* NOTE: `Element` is NOT the same as `type { Element } from 'react'` a.k.a React$Element
*
* To use it as a typical node, check with `if (node instanceof HTMLElement) { ... }`
*/
if (typeof exports !== "undefined") Object.defineProperty(exports, "babelPluginFlowReactPropTypes_proptype_DOMNode", {
value:
require("prop-types").oneOfType(
[
typeof babelPluginFlowReactPropTypes_proptype_Element === "function" ? babelPluginFlowReactPropTypes_proptype_Element : require("prop-types").shape(babelPluginFlowReactPropTypes_proptype_Element),
typeof Text === "function" ? require("prop-types").instanceOf(Text) : require("prop-types").any
]
),
configurable: true
}); Nowhere in this file is |
Compared to when we encounter var babelPluginFlowReactPropTypes_proptype_Element = require('react').babelPluginFlowReactPropTypes_proptype_Element || require('prop-types').any; It seems like this plugin isn't recognizing global types from the dom. Am I on the right track? |
Yeah, we don't have a list of global types. So, currently the solution is: const Element = window.Element;
type FooProps = {
element: Element,
}
class Foo extends React.Component {
props: FooProps;
render() { return null; }
} This does an instanceOf check. element: typeof Element === \\"function\\"
? require(\\"prop-types\\").instanceOf(Element).isRequired
: require(\\"prop-types\\").any.isRequired Are you thinking to have a list of global types flow supports, and do instanceOf checks on them if no type with that name is imported or defined? |
Thanks for the workaround. I was wondering what to do, it seems a bit overzealous to interpret as a global if not defined, but I guess that's how it works in the browser anyway. So, I think implementing a whitelisted set of globals could be the correct solution here. |
It seems the workaround didn't work. Source: const Element = window.Element;
const Text = window.Text;
export type DOMNode = Element | Text | null; build: var Element = window.Element;
var Text = window.Text;
if (typeof exports !== "undefined") Object.defineProperty(exports, "babelPluginFlowReactPropTypes_proptype_DOMNode", {
value:
require("prop-types").oneOfType([
typeof babelPluginFlowReactPropTypes_proptype_Element === "function" ? babelPluginFlowReactPropTypes_proptype_Element : require("prop-types").shape(babelPluginFlowReactPropTypes_proptype_Element),
typeof Text === "function" ? require("prop-types").instanceOf(Text) : require("prop-types").any
]),
configurable: true
}); |
Source (mimicing result of
findDOMNode()
):Usage is causing:
/see mui/material-ui#7400
Does use of the DOM
Element
require an explicitimport type
for compatibility with this plugin?The text was updated successfully, but these errors were encountered: