Arj*_*One 7 typescript reactjs react-native nrwl-nx
我一直在使用 Mono 存储库与 React 应用程序共享 React Native 组件。当我尝试使用 React 中的 React Native 组件时,它一直显示一个我无法解决的错误。
我尝试按照说明进行操作,例如将 @babel/preset-flow 添加到预设中。但是,还是没有用。请帮帮我。
请看看我遇到的错误:
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:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\parser\lib\index.js:67:32)
at constructor (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\parser\lib\index.js:364:12)
at Parser.raise (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\parser\lib\index.js:3365:19)
at Parser.expectOnePlugin (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\parser\lib\index.js:3414:18)
at Parser.isExportDefaultSpecifier (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\parser\lib\index.js:14261:16)
at Parser.maybeParseExportDefaultSpecifier (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\parser\lib\index.js:14158:14)
at Parser.parseExport (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\parser\lib\index.js:14088:29)
at Parser.parseStatementContent (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\parser\lib\index.js:13073:27)
at Parser.parseStatementLike (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\parser\lib\index.js:12952:17)
at Parser.parseModuleItem (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\parser\lib\index.js:12933:17)
at Parser.parseBlockOrModuleBlockBody (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\parser\lib\index.js:13558:36)
at Parser.parseBlockBody (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\parser\lib\index.js:13550:10)
at Parser.parseProgram (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\parser\lib\index.js:12842:10)
at Parser.parseTopLevel (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\parser\lib\index.js:12832:25)
at Parser.parse (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\parser\lib\index.js:14740:10)
at parse (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\parser\lib\index.js:14782:38)
at parser (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\core\lib\parser\index.js:41:34)
at parser.next (<anonymous>)
at normalizeFile (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\core\lib\transformation\normalize-file.js:66:38)
at normalizeFile.next (<anonymous>)
at run (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\core\lib\transformation\index.js:21:50)
at run.next (<anonymous>)
at transform (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\core\lib\transform.js:22:41)
at transform.next (<anonymous>)
at step (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\gensync\index.js:261:32)
at D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\gensync\index.js:273:13
at async.call.result.err.err (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\gensync\index.js:223:11)
at D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\gensync\index.js:189:28
at D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\@babel\core\lib\gensync-utils\async.js:72:7
at D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\gensync\index.js:113:33
at step (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\gensync\index.js:287:14)
at D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\gensync\index.js:273:13
at async.call.result.err.err (D:\workStation\Stacks\TurboRepoCrossPlatform\master\node_modules\gensync\index.js:223:11)
webpack compiled with 1 error (088b5b6bf6422082)```
Run Code Online (Sandbox Code Playgroud)
小智 6
您需要安装@babel/preset-typescript作为开发依赖项并添加您的 babel 配置。
npm install --save-dev @babel/preset-typescript
在你的 babel 配置 ( .babelrc) 文件中应该将其添加到你的预设中:
"presets": ["@babel/preset-typescript"]