Skip to content
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

Property specifiers expected type of array but got null #198

Closed
CHNB128 opened this issue Jun 11, 2021 · 28 comments
Closed

Property specifiers expected type of array but got null #198

CHNB128 opened this issue Jun 11, 2021 · 28 comments

Comments

@CHNB128
Copy link

CHNB128 commented Jun 11, 2021

I launch application one day and got this error while bundling:

[Fri Jun 11 2021 11:45:38.105]  BUNDLE  ./index.android.js 

error: node_modules/react-native-safe-area-context/src/SafeArea.types.ts: /home/gnome/src/urbest/z-frontend/node_modules/react-native-safe-area-context/src/SafeArea.types.ts: Property specifiers expected type of array but got null

I can't determinate what went wrong. May be I change something in usage of SafeAreaView so it got null where should be array or something else.

@jbolter
Copy link

jbolter commented Jun 11, 2021

I just started seeing this as well and I'm wondering what changed 🤔

@khattab93
Copy link

Me too. Could anyone help me fix this?

@taylorkline
Copy link

taylorkline commented Jun 14, 2021

I see this after upgrading from react-native v0.61.5 to v0.62.2.

safe-area-context is a dependency of react-navigation, here are my version numbers:

        "react-navigation": "^4.0.0",
        "react-navigation-drawer": "^2.7.0",
        "react-navigation-stack": "^2.10.4",

When I switch back to my branch on v0.61.5, I no longer have this issue.

@taylorkline
Copy link

@CHNB128 @jbolter @khattab93 Can each of you share information about your react-native and react-navigation versions?

@khattab93
Copy link

@taylorkline "react-native": "0.63.4" and I am using react native navigation

@CHNB128
Copy link
Author

CHNB128 commented Jun 16, 2021

@taylorkline

"react-native-safe-area-context": "^3.2.0",
"react-native": "0.63.4",

And we don't use react-navigation, because we have to outdated project, so it's a lot to change to migrate to it.

@CHNB128
Copy link
Author

CHNB128 commented Jun 16, 2021

I have red some resources about similar errors:
nrwl/nx#3202 (comment)
babel/babel#4342 (comment)
https://stackoverflow.com/a/35404879
facebook/regenerator#391
kentcdodds/babel-plugin-codegen#17
And it's look like error during babel compilation, even if this error happens during bundling.
So, can @taylorkline @khattab93 @harking also provide some information about your babel setup, which version of babel related dependencies you using (whole package.json dependencies section would be great)?

@taylorkline
Copy link

Note I upgraded to React Native v0.64.2 in hopes that would fix the issue - it didn't.

Current dependencies:

"dependencies": {
    "@bugsnag/react-native": "^7.5.2",
    "@invertase/react-native-apple-authentication": "^2.1.1",
    "@mapbox/polyline": "^1.0.0",
    "@react-native-community/async-storage": "^1.6.1",
    "@react-native-community/cameraroll": "^4.0.0",
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/google-signin": "^4.0.3",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/netinfo": "^3.2.1",
    "@react-native-community/push-notification-ios": "^1.8.0",
    "@react-native-firebase/analytics": "11.4.1",
    "@react-native-firebase/app": "11.4.1",
    "axios": "^0.18.0",
    "axios-mock-adapter": "^1.15.0",
    "date-fns": "^1.29.0",
    "lodash": "^4.17.10",
    "prop-types": "^15.7.2",
    "qs": "^6.5.2",
    "react": "17.0.1",
    "react-native": "0.64.2",
    "react-native-actionsheet": "^2.4.2",
    "react-native-animatable": "^1.3.3",
    "react-native-device-info": "^2.3.2",
    "react-native-fbsdk-next": "^4.0.0",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-idfa": "^4.1.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.2",
    "react-native-keyboard-aware-scrollview": "^2.0.0",
    "react-native-linear-gradient": "^2.4.0",
    "react-native-localization": "2.1.6",
    "react-native-map-link": "^2.4.5",
    "react-native-maps": "^0.27.1",
    "react-native-permissions": "2.2.2",
    "react-native-platform-touchable": "^1.1.1",
    "react-native-push-notification": "7.3.1",
    "react-native-reanimated": "1.13.1",
    "react-native-safe-area-context": "^3.2.0",
    "react-native-screens": "^2.18.1",
    "react-native-sensitive-info": "^5.5.0",
    "react-native-snap-carousel": "3.7.2",
    "react-native-splash-screen": "3.2.0",
    "react-native-store-review": "^0.1.5",
    "react-native-video": "^4.4.4",
    "react-native-view-shot": "3.1.2",
    "react-native-webview": "^10.8.3",
    "react-navigation": "^4.0.0",
    "react-navigation-drawer": "^2.7.0",
    "react-navigation-stack": "^2.10.4",
    "react-redux": "^5.1.2",
    "redux": "^4.0.0",
    "redux-thunk": "^2.3.0",
    "uuid": "^3.3.2"
},
"devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "babel-eslint": "^8.2.3",
    "babel-jest": "^26.6.3",
    "deep-freeze": "^0.0.1",
    "eslint": "^4.19.1",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-react": "^7.7.0",
    "eslint-plugin-react-hooks": "^3.0.0",
    "eslint-plugin-react-native": "^3.2.1",
    "jest": "^26.6.3",
    "jest-junit": "^6.3.0",
    "metro-react-native-babel-preset": "^0.64.0",
    "patch-package": "^6.2.2",
    "prettier": "1.12.1",
    "react-native-clean-project": "^3.4.0",
    "react-test-renderer": "17.0.1",
    "redux-logger": "^3.0.6",
    "redux-mock-store": "^1.5.3"
},

@CHNB128
Copy link
Author

CHNB128 commented Jun 16, 2021

Note I upgraded to React Native v0.64.2 in hopes that would fix the issue - it didn't.

I also thought about it, but same.
Thanks for your replay. It's great to not be alone in this :)

@CHNB128
Copy link
Author

CHNB128 commented Jun 16, 2021

  "dependencies": {
    "@cljs-oss/module-deps": "^1.1.1",
    "@react-native-community/async-storage": "^1.6.2",
    "@react-native-community/netinfo": "^4.2.1",
    "@react-native-community/push-notification-ios": "^1.8.0",
    "@react-native-firebase/analytics": "^10.8.1",
    "@react-native-firebase/app": "^10.8.1",
    "@react-native-firebase/crashlytics": "^10.8.1",
    "@react-native-firebase/messaging": "^10.8.1",
    "@sentry/react-native": "^1.0.5",
    "amplitude-js": "^5.8.0",
    "create-react-class": "15.6.3",
    "cypress-file-upload": "^4.0.7",
    "detox": "^16.7.1",
    "hermes-engine": "^0.2.1",
    "immutable": "^4.0.0-rc.12",
    "mocha": "^7.2.0",
    "react": "16.13.1",
    "react-dom": "16.9.0",
    "react-native": "0.63.4",
    "react-native-android-location-enabler": "^1.2.2",
    "react-native-calendars": "^1.204.0",
    "react-native-charts-wrapper": "^0.5.7",
    "react-native-code-push": "^7.0.0",
    "react-native-config": "^1.4.2",
    "react-native-device-info": "^3.1.1",
    "react-native-dialogs": "^1.0.5",
    "react-native-document-picker": "^3.2.4",
    "react-native-fast-image": "^8.3.4",
    "react-native-geolocation-service": "^5.2.0",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-image-crop-picker": "^0.36.2",
    "react-native-image-zoom-viewer": "^3.0.1",
    "react-native-interactable": "https://github.com/wix/react-native-interactable.git#master",
    "react-native-keyboard-aware-scroll-view": "^0.9.4",
    "react-native-localize": "^1.2.0",
    "react-native-maps": "^0.28.0",
    "react-native-modal": "11.10.0",
    "react-native-orientation": "^3.1.3",
    "react-native-permissions": "^3.0.4",
    "react-native-push-notification": "^7.3.1",
    "react-native-reanimated": "^1.2.0",
    "react-native-root-toast": "^3.1.2",
    "react-native-safe-area-context": "^3.2.0",
    "react-native-screens": "2.0.0",
    "react-native-snap-carousel": "^3.8.0",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "12.1.0",
    "react-navigation": "^4.0.5",
    "react-navigation-stack": "^1.7.3",
    "react-navigation-tabs": "^2.5.2",
    "supercluster": "^6.0.1",
    "xmlhttprequest": "^1.8.0"
  },
  "devDependencies": {
    "@babel/core": "^7.8.4",
    "@babel/runtime": "^7.8.4",
    "@react-native-community/cli": "4.14.0",
    "@sentry/cli": "^1.49.0",
    "autoprefixer": "^9.6.4",
    "babel-jest": "^25.1.0",
    "bundlesize": "^0.17.2",
    "cssnano": "^4.1.10",
    "cypress": "4.6.0",
    "cypress-plugin-retries": "^1.5.2",
    "jest": "^25.1.0",
    "jetifier": "^1.6.2",
    "metro-react-native-babel-preset": "^0.59.0",
    "mqpacker": "^7.0.0",
    "patch-package": "^6.0.5",
    "postcss-cli": "^6.1.3",
    "react-test-renderer": "16.13.1",
    "serve": "^11.3.2"
  },

@CHNB128
Copy link
Author

CHNB128 commented Jun 16, 2021

I created discussion about this in https://github.com/babel/babel, may be some one will help us.

@nicolo-ribaudo
Copy link

Babel maintainer here. Does anyone have a complete stack trace or a repository I can clone and run a build command to reproduce the error?

@CHNB128
Copy link
Author

CHNB128 commented Jun 16, 2021

Babel maintainer here. Does anyone have a complete stack trace or a repository I can clone and run a build command to reproduce the error?

@nicolo-ribaudo
I can't get full stack trace. It would be great actually, if I can get it, but metro collapse it and we can get only this error line, even when I provide --verbose option to it.
About to provide full repo to you, I also can't do it. It under commercial protection.

@nicolo-ribaudo
Copy link

nicolo-ribaudo commented Jun 16, 2021

The error is thrown at line 158 of https://unpkg.com/browse/@babel/types@7.14.5/lib/definitions/utils.js (it might be a slightly different line if you have a different @babel/types version).

Could you try editing it like this? Maybe metro will give us a stack trace.

function assertValueType(type) {
  function validate(node, key, val) {
    const valid = getType(val) === type;

    if (!valid) {
+     Error.stackTraceLimit = 100;
+     console.trace("ERROR HERE!");
      throw new TypeError(`Property ${key} expected type of ${type} but got ${getType(val)}`);
    }
  }

  validate.type = type;
  return validate;
}

@CHNB128
Copy link
Author

CHNB128 commented Jun 16, 2021

@nicolo-ribaudo
We got it!

transform[stderr]: Trace: ERROR HERE!
transform[stderr]:     at validate (/home/gnome/src/urbest/z-frontend/node_modules/@babel/types/lib/definitions/utils.js:165:15)
transform[stderr]:     at Object.validate (/home/gnome/src/urbest/z-frontend/node_modules/@babel/types/lib/definitions/utils.js:203:7)
transform[stderr]:     at validateField (/home/gnome/src/urbest/z-frontend/node_modules/@babel/types/lib/validators/validate.js:22:9)
transform[stderr]:     at validate (/home/gnome/src/urbest/z-frontend/node_modules/@babel/types/lib/validators/validate.js:16:3)
transform[stderr]:     at builder (/home/gnome/src/urbest/z-frontend/node_modules/@babel/types/lib/builders/builder.js:46:27)
transform[stderr]:     at Object.ExportNamedDeclaration (/home/gnome/src/urbest/z-frontend/node_modules/@babel/types/lib/builders/generated/index.js:477:31)
transform[stderr]:     at PluginPass.exit (/home/gnome/src/urbest/z-frontend/node_modules/@babel/plugin-transform-typescript/lib/index.js:270:52)
transform[stderr]:     at newFn (/home/gnome/src/urbest/z-frontend/node_modules/@babel/core/node_modules/@babel/traverse/lib/visitors.js:171:21)
transform[stderr]:     at NodePath._call (/home/gnome/src/urbest/z-frontend/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:53:20)
transform[stderr]:     at NodePath.call (/home/gnome/src/urbest/z-frontend/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:40:17)
transform[stderr]:     at NodePath.visit (/home/gnome/src/urbest/z-frontend/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:99:8)
transform[stderr]:     at TraversalContext.visitQueue (/home/gnome/src/urbest/z-frontend/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:110:16)
transform[stderr]:     at TraversalContext.visitSingle (/home/gnome/src/urbest/z-frontend/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:79:19)
transform[stderr]:     at TraversalContext.visit (/home/gnome/src/urbest/z-frontend/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:138:19)
transform[stderr]:     at Function.traverse.node (/home/gnome/src/urbest/z-frontend/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:76:17)
transform[stderr]:     at traverse (/home/gnome/src/urbest/z-frontend/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:56:12)
transform[stderr]:     at transformFile (/home/gnome/src/urbest/z-frontend/node_modules/@babel/core/lib/transformation/index.js:105:29)
transform[stderr]:     at transformFile.next (<anonymous>)
transform[stderr]:     at run (/home/gnome/src/urbest/z-frontend/node_modules/@babel/core/lib/transformation/index.js:33:12)
transform[stderr]:     at run.next (<anonymous>)
transform[stderr]:     at /home/gnome/src/urbest/z-frontend/node_modules/@babel/core/lib/transform-ast.js:26:41
transform[stderr]:     at Generator.next (<anonymous>)
transform[stderr]:     at evaluateSync (/home/gnome/src/urbest/z-frontend/node_modules/gensync/index.js:251:28)
transform[stderr]:     at sync (/home/gnome/src/urbest/z-frontend/node_modules/gensync/index.js:89:14)
transform[stderr]:     at Object.transform (/home/gnome/src/urbest/z-frontend/node_modules/metro-react-native-babel-transformer/src/index.js:251:20)
transform[stderr]:     at /home/gnome/src/urbest/z-frontend/node_modules/metro/src/JSTransformer/worker.js:242:31
transform[stderr]:     at Generator.next (<anonymous>)
transform[stderr]:     at asyncGeneratorStep (/home/gnome/src/urbest/z-frontend/node_modules/metro/src/JSTransformer/worker.js:75:24)
transform[stderr]:     at _next (/home/gnome/src/urbest/z-frontend/node_modules/metro/src/JSTransformer/worker.js:95:9)
transform[stderr]:     at /home/gnome/src/urbest/z-frontend/node_modules/metro/src/JSTransformer/worker.js:100:7
transform[stderr]:     at new Promise (<anonymous>)
transform[stderr]:     at /home/gnome/src/urbest/z-frontend/node_modules/metro/src/JSTransformer/worker.js:92:12
transform[stderr]:     at JsTransformer.transform (/home/gnome/src/urbest/z-frontend/node_modules/metro/src/JSTransformer/worker.js:401:7)
transform[stderr]:     at Object.<anonymous> (/home/gnome/src/urbest/z-frontend/node_modules/metro/src/DeltaBundler/Worker.js:102:38)
transform[stderr]:     at Generator.next (<anonymous>)
transform[stderr]:     at asyncGeneratorStep (/home/gnome/src/urbest/z-frontend/node_modules/metro/src/DeltaBundler/Worker.js:14:24)
transform[stderr]:     at _next (/home/gnome/src/urbest/z-frontend/node_modules/metro/src/DeltaBundler/Worker.js:34:9)
transform[stderr]:     at /home/gnome/src/urbest/z-frontend/node_modules/metro/src/DeltaBundler/Worker.js:39:7
transform[stderr]:     at new Promise (<anonymous>)
transform[stderr]:     at Object.<anonymous> (/home/gnome/src/urbest/z-frontend/node_modules/metro/src/DeltaBundler/Worker.js:31:12)
transform[stderr]:     at Object.transform (/home/gnome/src/urbest/z-frontend/node_modules/metro/src/DeltaBundler/Worker.js:79:21)
transform[stderr]:     at execFunction (/home/gnome/src/urbest/z-frontend/node_modules/metro/node_modules/jest-worker/build/workers/processChild.js:155:17)
transform[stderr]:     at execHelper (/home/gnome/src/urbest/z-frontend/node_modules/metro/node_modules/jest-worker/build/workers/processChild.js:139:5)
transform[stderr]:     at execMethod (/home/gnome/src/urbest/z-frontend/node_modules/metro/node_modules/jest-worker/build/workers/processChild.js:143:5)
transform[stderr]:     at process.<anonymous> (/home/gnome/src/urbest/z-frontend/node_modules/metro/node_modules/jest-worker/build/workers/processChild.js:64:7)
transform[stderr]:     at process.emit (events.js:315:20)
transform[stderr]:     at emit (internal/child_process.js:903:12)
transform[stderr]:     at processTicksAndRejections (internal/process/task_queues.js:81:21)

@CHNB128
Copy link
Author

CHNB128 commented Jun 16, 2021

Bit more about it.
it's node value of validate function, if it will help.

transform[stdout]: {
transform[stdout]:   type: 'ExportNamedDeclaration',
transform[stdout]:   declaration: null,
transform[stdout]:   specifiers: null,
transform[stdout]:   source: null
transform[stdout]: }

@nicolo-ribaudo
Copy link

nicolo-ribaudo commented Jun 16, 2021

Thanks, I'm trying to reproduce the bug using that stack trace 👍

This seems to be a Babel bug, not caused by this project.

@nicolo-ribaudo
Copy link

Can you check the version of /home/gnome/src/urbest/z-frontend/node_modules/@babel/types?

@CHNB128
Copy link
Author

CHNB128 commented Jun 16, 2021

The highest version I have in .lock file is:

  dependencies:
    "@babel/types" "^7.14.5"

@nicolo-ribaudo
Copy link

Can you check what /home/gnome/src/urbest/z-frontend/node_modules/@babel/types/package.json says? Looking at the code, this error should have been fixed in @babel/types 7.8.0 🤔

@CHNB128
Copy link
Author

CHNB128 commented Jun 16, 2021

Yes, it's 7.14.5 in it.

@nicolo-ribaudo
Copy link

Can you also try logging args (other than node) for that validate call?
It should be an empty array, but I think that for some reason it's something like [null, null, null].

@khattab93
Copy link

I solved it by removing yarn.lock and package-lock.json and then running yarn install

@CHNB128
Copy link
Author

CHNB128 commented Jun 18, 2021

So, as I understood problem was that yarn or npm incorrectly resolved dependencies, which produce this strange error.
Thanks all of you for helping with it.
Think issue can be closed soon.

@taylorkline
Copy link

We have a workaround, not a solution. I disagree with closing this issue. Something is wrong with some dependencies somewhere.

@nicolo-ribaudo My babel types version is actually 7.5.5.

And here are the arguments to the validate call:

transform[stdout]: node {
transform[stdout]:   type: 'ExportNamedDeclaration',
transform[stdout]:   declaration: null,
transform[stdout]:   specifiers: null,
transform[stdout]:   source: null
transform[stdout]: }
transform[stdout]: key specifiers
transform[stdout]: val null
transform[stdout]: type array

@taylorkline
Copy link

As a less heavy-handed workaround, I specifically removed the @babel/types entries from my yarn.lock and re-ran yarn. Now my @babel/types resolved to 7.14.5 and all works correctly.

@uzegonemad
Copy link

I had two entries for @babel/types in my yarn.lock file which resolved to 7.6.1 and 7.15.0. Instead of manually modifying my lock file, I ran npx yarn-deduplicate to handle the multiple entries. Afterward the only entry was for 7.15.0 which resolved this error.

@jacobp100
Copy link
Collaborator

This is for v3 of the library, and we're on v4. Please re-open a new issue if you're still facing issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants