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

SyntaxError: Unexpected token (10:13) when NativeModules is used #122

Open
rumax opened this issue Nov 7, 2020 · 1 comment
Open

SyntaxError: Unexpected token (10:13) when NativeModules is used #122

rumax opened this issue Nov 7, 2020 · 1 comment

Comments

@rumax
Copy link

rumax commented Nov 7, 2020

Hi,

I'm trying to use flowgen for my project that I want to migrate to TypeScript but getting an exception. I was able to simplify the case to:

import { NativeModules } from 'react-native';

const { RNSaveView } = NativeModules;

export default ErrorUtils;

So it seems like NativeModules are not supported?

The result of execution is:

$ ./node_modules/.bin/flowgen src/index.ts --output-file lib/index.js.flow
Parsing index.ts
SyntaxError: Unexpected token (10:13)
   8 |           NativeModules
   9 |         } from 'react-native';
> 10 | declare var : any // NativeModules
     |             ^
  11 | ;declare export default typeof ErrorUtils
  12 | 
    at t (/Users/user/react-native-SaveView/node_modules/prettier/parser-babel.js:1:317)
    at Object.parse (/Users/user/react-native-SaveView/node_modules/prettier/parser-babel.js:1:291098)
    at Object.parse (/Users/user/react-native-SaveView/node_modules/prettier/index.js:13575:19)
    at coreFormat (/Users/user/react-native-SaveView/node_modules/prettier/index.js:14851:25)
    at format (/Users/user/react-native-SaveView/node_modules/prettier/index.js:15073:14)
    at formatWithCursor (/Users/user/react-native-SaveView/node_modules/prettier/index.js:15090:12)
    at /Users/user/react-native-SaveView/node_modules/prettier/index.js:54691:12
    at Object.format (/Users/user/react-native-SaveView/node_modules/prettier/index.js:54711:12)
    at beautify (/Users/user/react-native-SaveView/node_modules/flowgen/lib/cli/beautifier.js:11:28)
    at outputFile (/Users/user/react-native-SaveView/node_modules/flowgen/lib/cli/runner.js:40:38) {
  loc: { start: { line: 10, column: 13 } },
  codeFrame: '\u001b[0m \u001b[90m  8 | \u001b[39m          \u001b[33mNativeModules\u001b[39m\u001b[0m\n' +
    "\u001b[0m \u001b[90m  9 | \u001b[39m        } from \u001b[32m'react-native'\u001b[39m\u001b[33m;\u001b[39m\u001b[0m\n" +
    '\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 10 | \u001b[39mdeclare \u001b[36mvar\u001b[39m \u001b[33m:\u001b[39m any \u001b[90m// NativeModules\u001b[39m\u001b[0m\n' +
    '\u001b[0m \u001b[90m    | \u001b[39m            \u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[0m\n' +
    '\u001b[0m \u001b[90m 11 | \u001b[39m\u001b[33m;\u001b[39mdeclare \u001b[36mexport\u001b[39m \u001b[36mdefault\u001b[39m \u001b[36mtypeof\u001b[39m \u001b[33mErrorUtils\u001b[39m\u001b[0m\n' +
    '\u001b[0m \u001b[90m 12 | \u001b[39m\u001b[0m'
}

Or am I missing something?

@dephiros
Copy link

dephiros commented Apr 1, 2021

Ran into this issue as well

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

2 participants