Open semireg opened 6 years ago
This command can be used to generate the error:
$ react-native bundle --platform ios --entry-file index.js --bundle-output ./ios/main.jsbundle
Loading dependency graph, done.
node_modules/react-native/Libraries/Components/RefreshControl/RefreshControl.js: Property value expected type of string but got object
TypeError: Property value expected type of string but got object
at Object.validate (/Users/devuser/local-dev/rn/RNSemiBoilerplate/node_modules/babel-types/lib/definitions/index.js:161:13)
at validate (/Users/devuser/local-dev/rn/RNSemiBoilerplate/node_modules/babel-types/lib/index.js:505:9)
at Object.builder (/Users/devuser/local-dev/rn/RNSemiBoilerplate/node_modules/babel-types/lib/index.js:466:7)
at qualifiedToMemberExpression (/Users/devuser/local-dev/rn/RNSemiBoilerplate/node_modules/babel-plugin-flow-runtime/lib/convert.js:217:19)
at annotationToValue (/Users/devuser/local-dev/rn/RNSemiBoilerplate/node_modules/babel-plugin-flow-runtime/lib/convert.js:247:14)
at annotationToValue (/Users/devuser/local-dev/rn/RNSemiBoilerplate/node_modules/babel-plugin-flow-runtime/lib/convert.js:245:14)
at converters.TypeofTypeAnnotation (/Users/devuser/local-dev/rn/RNSemiBoilerplate/node_modules/babel-plugin-flow-runtime/lib/convert.js:411:15)
at convert (/Users/devuser/local-dev/rn/RNSemiBoilerplate/node_modules/babel-plugin-flow-runtime/lib/convert.js:52:16)
at /Users/devuser/local-dev/rn/RNSemiBoilerplate/node_modules/babel-plugin-flow-runtime/lib/convert.js:533:12
This seems to be related to flow-runtime lacking babel 7 support https://github.com/codemix/flow-runtime/issues/184. Fwiw, "babel-types" is babel version 6. Perhaps that is causing the underlying issue. I've since removed flow-runtime support from master branch of https://github.com/semireg/RNSemiBoilerplate.
This is turning out to be a very interesting error and possibly a bug. I distilled the issue down to this failing test:
export const input = `
// var Foo;
if (true) {
var Foo = {BAR: {}};
} else {
var Foo = {BAR: {}};
}
type test = { thing: Foo.BAR };
`;
When var Foo
is not declared, the test fails with the same TypeError Property value expected type of string but got null
, deep within babel type validators. If you uncomment the declaration, you'll see a standard test failure because the test isn't fully setup (const expected = ``;
).
Here's the offending lines from RefreshControl.js:
if (Platform.OS === 'android') {
const AndroidSwipeRefreshLayout = require('UIManager')
.AndroidSwipeRefreshLayout;
var RefreshLayoutConsts = AndroidSwipeRefreshLayout
? AndroidSwipeRefreshLayout.Constants
: {SIZE: {}};
} else {
var RefreshLayoutConsts = {SIZE: {}};
}
And low and behold... https://github.com/facebook/react-native/commit/a06c0da828f42b804b526a5de35b94b5b4468c1c
💯
I'm going to leave this issue open until it gets released.
This is a:
Which concerns:
What is the current behaviour?
Reproducible repo at https://github.com/semireg/RNSemiBoilerplate/tree/fa3829669fda5cb5396eea26a6021513103f7357. This react native boilerplate uses RN 0.57.4, babel 7, flow, flow-runtime, immutable, redux, redux-immutable.
App build is broken due to TransformError when native app loads bundle.
iOS:
Android:
What is the expected behaviour?
Build should bundle and load without error.
I've tried clearing my caches/tmp directories, build assets, etc via:
If the repo above does not reproduce the error, can anyone think of other directories that I need to reset that could be tainted?
I have searched GitHub issues, Google, and Stack Overflow and can not find any similar issues.
Which package versions are you using?
.babelrc