AsyncStorage.js: Unexpected token, expected ";" (40:5)
See original GitHub issueHi, I got this error when I am trying to compile:
Starting compilation in watch mode...
Found 0 errors. Watching for file changes.
Starting the development server...
Failed to compile.
/Users/myuser/Developer/tindev-monorepo/node_modules/@react-native-community/async-storage/lib/AsyncStorage.js
SyntaxError: /Users/myuser/Developer/tindev-monorepo/node_modules/@react-native-community/async-storage/lib/AsyncStorage.js: Unexpected token, expected ";" (40:5)
38 | }
39 |
> 40 | type ReadOnlyArrayString = $ReadOnlyArray<string>;
| ^
41 |
42 | type MultiGetCallbackFunction = (
43 | errors: ?$ReadOnlyArray<Error>,
Versions:
“@react-native-community/async-storage”: “^1.6.1”, “react-native-web”: “0.11.1”, “react-native”: “^0.60.5”
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:7 (3 by maintainers)
Top Results From Across the Web
JSON.parse(object) when getting from asyncStorage throws ...
JSON.parse(object) when getting from asyncStorage throws error: Unexpected token o in JSON at position 1 ; JSON.stringyfy , is that a typo or...
Read more >AsyncStorage.js: Unexpected token, expected ";" : r/reactnative
No, async storage uses sqlite, mmkv reads and writes data to text file. You can use 2 of them same time. If you...
Read more >AsyncStorage · React Native
The AsyncStorage JavaScript code is a facade that provides a clear JavaScript API, real Error objects, and non-multi functions.
Read more >jest SyntaxError: Unexpected token Code Example
Uncaught (in promise) DOMException: Failed to load because no supported source was found. ... This can also happen when the JS bundle is...
Read more >How To Use React Native AsyncStorage - JScrambler Blog
This reading and writing of data are going to be done with the help of AsyncStorage API functions. Open the App.js file and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Getting the same error with this code
when compiling for the WEB. I don’t understand why bundler still tries to import it when it clearly shouldn’t. I tried resetting cache, yarn and deleting node_modules folders with no luck. And the only way Im able to make it work is explicitly writing
const storage = require("localforage")
and removingrequire("@react-native-community/async-storage")
line completely. This is so strange.Update: resolved my issue by adding
path.resolve('../../node_modules/@react-native-community/async-storage')
line intobabelInclude([])
section inpackages/web/config-overrides.js
file.@muazazhar: This issue is probably no longer relevant to the error you’re seeing. We’ve sinced migrated AsyncStorage to TypeScript. If you’re still seeing Flow issues, it’s not because of AsyncStorage.