skip to Main Content

I’ve been using a Mono repo to share react native components with react app. when I was trying to use a react native component from react, it has been showing an error which I couldn’t resolve.

I’ve tried to follow the instructions like adding @babel/preset-flow to presets. But, still no use. Please help me out.

please Look At the error i’ve been facing:


   5 |
   6 | /* eslint-disable-next-line */
>  7 | export interface TestingProps {
     |        ^
   8 | }
   9 |
  10 |

Add @babel/preset-flow (https://github.com/babel/babel/tree/main/packages/babel-preset-flow) to the 'presets' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-flow (https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-flow) to the 'plugins' section to enable parsing.
    at instantiate (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelparserlibindex.js:67:32)  
    at constructor (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelparserlibindex.js:364:12) 
    at Parser.raise (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelparserlibindex.js:3365:19)
    at Parser.expectOnePlugin (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelparserlibindex.js:3414:18)
    at Parser.isExportDefaultSpecifier (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelparserlibindex.js:14261:16)
    at Parser.maybeParseExportDefaultSpecifier (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelparserlibindex.js:14158:14)
    at Parser.parseExport (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelparserlibindex.js:14088:29)
    at Parser.parseStatementContent (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelparserlibindex.js:13073:27)
    at Parser.parseStatementLike (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelparserlibindex.js:12952:17)
    at Parser.parseModuleItem (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelparserlibindex.js:12933:17)
    at Parser.parseBlockOrModuleBlockBody (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelparserlibindex.js:13558:36)
    at Parser.parseBlockBody (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelparserlibindex.js:13550:10)
    at Parser.parseProgram (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelparserlibindex.js:12842:10)
    at Parser.parseTopLevel (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelparserlibindex.js:12832:25)
    at Parser.parse (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelparserlibindex.js:14740:10)
    at parse (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelparserlibindex.js:14782:38)     
    at parser (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelcorelibparserindex.js:41:34)  
    at parser.next (<anonymous>)
    at normalizeFile (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelcorelibtransformationnormalize-file.js:66:38)
    at normalizeFile.next (<anonymous>)
    at run (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelcorelibtransformationindex.js:21:50)
    at run.next (<anonymous>)
    at transform (D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelcorelibtransform.js:22:41)  
    at transform.next (<anonymous>)
    at step (D:workStationStacksTurboRepoCrossPlatformmasternode_modulesgensyncindex.js:261:32)
    at D:workStationStacksTurboRepoCrossPlatformmasternode_modulesgensyncindex.js:273:13
    at async.call.result.err.err (D:workStationStacksTurboRepoCrossPlatformmasternode_modulesgensyncindex.js:223:11)
    at D:workStationStacksTurboRepoCrossPlatformmasternode_modulesgensyncindex.js:189:28
    at D:workStationStacksTurboRepoCrossPlatformmasternode_modules@babelcorelibgensync-utilsasync.js:72:7     
    at D:workStationStacksTurboRepoCrossPlatformmasternode_modulesgensyncindex.js:113:33
    at step (D:workStationStacksTurboRepoCrossPlatformmasternode_modulesgensyncindex.js:287:14)
    at D:workStationStacksTurboRepoCrossPlatformmasternode_modulesgensyncindex.js:273:13
    at async.call.result.err.err (D:workStationStacksTurboRepoCrossPlatformmasternode_modulesgensyncindex.js:223:11)

webpack compiled with 1 error (088b5b6bf6422082)```

2

Answers


  1. You need to install @babel/preset-typescript as a dev dependency and add to it your babel config.

    npm install --save-dev @babel/preset-typescript

    In your babel config (.babelrc) file should then add this to your presets:

    "presets": ["@babel/preset-typescript"]

    Login or Signup to reply.
  2. First answer didn’t work for me, but adding options to main.js helped:

    babel: async (options) => {
            options.plugins.push('@babel/plugin-syntax-flow');
            options.presets.push('@babel/preset-typescript');
            return options;
        }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search