Consider the following two files:
dep.js
// @flow
export type Fruit = string; // doesn't matter
test.js
// @flow
import * as Dep from "./dep.js";
export type Fruit = Dep.Fruit;
These files type-check (yarn flow check) without problem.
But the output of npx babel test.js is the following:
import * as Dep from "./dep.js";
var bpfrpt_proptype_Fruit = function () {
return (typeof (Dep.Fruit == null ? {} : Dep.Fruit) === "function" ? PropTypes.instanceOf(Dep.Fruit == null ? {} : Dep.Fruit) : PropTypes.any).apply(this, arguments);
};
import PropTypes from "prop-types";
export { bpfrpt_proptype_Fruit };
It is a runtime error to refer to Dep.Fruit, because that export only
exists at the type level.
.babelrc
{"presets": ["babel-preset-flow"], "plugins": ["babel-plugin-flow-react-proptypes"]}
package.json
{
"name": "demo",
"dependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-plugin-flow-react-proptypes": "^24.0.1",
"babel-preset-flow": "^6.23.0",
"flow-bin": "^0.75.0"
}
}
Consider the following two files:
dep.js
test.js
These files type-check (
yarn flow check) without problem.But the output of
npx babel test.jsis the following:It is a runtime error to refer to
Dep.Fruit, because that export onlyexists at the type level.
.babelrc
{"presets": ["babel-preset-flow"], "plugins": ["babel-plugin-flow-react-proptypes"]}package.json
{ "name": "demo", "dependencies": { "babel-cli": "^6.26.0", "babel-core": "^6.26.3", "babel-plugin-flow-react-proptypes": "^24.0.1", "babel-preset-flow": "^6.23.0", "flow-bin": "^0.75.0" } }