I created a new project. I have special folders for interfaces, types and etc. I will have a lot of them, so I import them into one file and export them from there. When I want to export multiple interfaces I get an error:
error: bundling failed: SyntaxError: C:\Users\QWERTY\Desktop\TestProjects\2019\TestProject\node_modules\react-native\scripts\src\types\PinCode\index.ts: Exporting local "IPinCodeParams", which is not declared. 13 | } 14 |> 15 | export { PinStatus, IPinCodeParams } | ^ at File.buildCodeFrameError (C:\Users\QWERTY\Desktop\TestProjects\2019\TestProject\node_modules\@babel\core\lib\transformation\file\file.js:261:12) at NodePath.buildCodeFrameError (C:\Users\QWERTY\Desktop\TestProjects\2019\TestProject\node_modules\@babel\traverse\lib\path\index.js:157:21) at getLocalMetadata (C:\Users\QWERTY\Desktop\TestProjects\2019\TestProject\node_modules\@babel\helper-module-transforms\lib\normalize-and-load-metadata.js:281:22) at child.get.forEach.spec (C:\Users\QWERTY\Desktop\TestProjects\2019\TestProject\node_modules\@babel\helper-module-transforms\lib\normalize-and-load-metadata.js:315:11) at Array.forEach (<anonymous>) at programPath.get.forEach.child (C:\Users\QWERTY\Desktop\TestProjects\2019\TestProject\node_modules\@babel\helper-module-transforms\lib\normalize-and-load-metadata.js:307:33) at Array.forEach (<anonymous>) at getLocalExportMetadata (C:\Users\QWERTY\Desktop\TestProjects\2019\TestProject\node_modules\@babel\helper-module-transforms\lib\normalize-and-load-metadata.js:294:27) at getModuleMetadata (C:\Users\QWERTY\Desktop\TestProjects\2019\TestProject\node_modules\@babel\helper-module-transforms\lib\normalize-and-load-metadata.js:86:21)
I have this folder structure:
android\ios\node_modules\src\--->constants\ |--->colors.ts |--->fonts.ts |--->index.ts--->router\ |--->index.ts--->screen\ |--->Splash\ |--->containers\ |--->index.ts |--->SplashContainer.tsx |--->views\ |--->index.ts |--->SplashView.tsx |--->index.tsx |--->index.ts--->types\ |--->PinCode\ |--->index.tsx |--->index.tsx--->App.tsx.babelrc***package.jsonrn-cli.config.jstsconfig.jsontslint.json
In the file "PinCode" I have an enum and an interface.
When I write so (all right):
export enum PinStatus { New = 'new', Confirm = 'confirm', Unlock = 'unlock', Edit = 'edit',}export interface IPinCodeParams { status: PinStatus; onComplete: () => void; onClose?: () => void; originalCode?: string;}
But when I write so (I get the error):
enum PinStatus { New = 'new', Confirm = 'confirm', Unlock = 'unlock', Edit = 'edit',}interface IPinCodeParams { status: PinStatus; onComplete: () => void; onClose?: () => void; originalCode?: string;}export { PinStatus, IPinCodeParams };
I have created some completely new projects, tried to rewrite this project several times, but nothing came out. I finally got this error anyway.
package.json
{"name": "TestProject","version": "0.0.1","private": true,"scripts": {"android": "node node_modules/react-native/local-cli/cli.js run-android","ios": "node node_modules/react-native/local-cli/cli.js run-ios","lint": "yarn tslint && yarn typecheck","tslint": "tslint --project tsconfig.json --config tslint.json src/**/*.ts{,x} --format stylish","typecheck": "tsc --project tsconfig.json --noEmit","postinstall": "typesync","type-sync": "typesync" },"husky": {"hooks": {"pre-commit": "yarn lint","pre-push": "yarn lint" } },"dependencies": {"mobx": "^4.9.2","mobx-persist": "^0.4.1","mobx-react": "^5.4.3","react": "16.8.0","react-native": "0.58.4","react-native-vector-icons": "^6.2.0","react-navigation": "^2.18.1" },"devDependencies": {"@babel/plugin-proposal-class-properties": "^7.3.0","@babel/plugin-proposal-decorators": "^7.3.0","@types/babel-core": "6.25.5","@types/jest": "24.0.0","@types/prettier": "^1.16.0","@types/react": "16.8.2","@types/react-native": "0.57.34","@types/react-native-vector-icons": "^4.6.4","@types/react-navigation": "^3.0.1","@types/react-test-renderer": "16.8.0","babel-core": "7.0.0-bridge.0","babel-jest": "24.1.0","babel-plugin-module-resolver": "^3.1.3","husky": "^1.3.1","jest": "24.1.0","jsc-android": "236355.1.1","metro-react-native-babel-preset": "0.51.1","mobx-logger": "^0.7.1","prettier": "^1.16.4","react-native-typescript-transformer": "^1.2.11","react-test-renderer": "16.6.3","tslint": "^5.12.1","tslint-config-prettier": "^1.18.0","tslint-eslint-rules": "^5.4.0","tslint-react": "^3.6.0","typescript": "^3.2.4","typesync": "^0.4.1" },"jest": {"preset": "react-native" }}
.babelrc
{"presets": ["module:metro-react-native-babel-preset", ],"plugins": [ ["@babel/plugin-proposal-decorators", {"legacy": true } ],"@babel/transform-react-jsx-source", ["module-resolver", {"root": ["/src" ],"alias": {"@api": "./src/api","@actions": "./src/actions","@components": "./src/components","@constants": "./src/constants","@hocs": "./src/hocs","@managers": "./src/managers","@locales": "./src/locales","@reducers": "./src/reducers","@screens": "./src/screens","@static": "./src/static","@stores": "./src/stores","@styles": "./src/styles","@types": "./src/types","@utils": "./src/utils" } } ], ]}
tsconfing.json
{"compilerOptions": {"target": "es2015","module": "commonjs","moduleResolution": "node","jsx": "react-native","baseUrl": "./src","outDir": "./dist","allowSyntheticDefaultImports": true,"declaration": true,"emitDecoratorMetadata": true,"experimentalDecorators": true,"noEmit": true,"noImplicitAny": false,"noUnusedLocals": true,"noUnusedParameters": true,"pretty": true,"skipLibCheck": true,"sourceMap": true,"strict": true,"paths": {"@api": ["api" ],"@actions": ["actions" ],"@components": ["components" ],"@constants": ["constants" ],"@hocs": ["hocs" ],"@managers": ["managers" ],"@locales": ["locales" ],"@reducers": ["reducers" ],"@screens": ["screens" ],"@static": ["static" ],"@stores": ["stores" ],"@styles": ["styles" ],"@types": ["types" ],"@utils": ["utils" ] } },}
tslist.json
{"defaultSeverity": "error","extends": ["tslint-config-prettier","tslint-eslint-rules","tslint-react","tslint:latest" ],"jsRules": {},"rules": {"await-promise": false,"interface-over-type-literal": false,"jsx-alignment": true,"jsx-boolean-value": false,"jsx-no-bind": true,"jsx-no-lambda": false,"max-classes-per-file": false,"member-access": false,"member-ordering": false,"no-constant-condition": false,"no-duplicate-imports": false,"no-empty": false,"no-implicit-dependencies": false,"no-submodule-imports": false,"object-literal-sort-keys": false,"ordered-imports": false,"quotemark": [ true,"single","jsx-single","avoid-escape" ],"semicolon": [ true,"always" ],"trailing-comma": [ true, {"singleline": "never","multiline": "always" } ],"triple-equals": [ true,"allow-undefined-check" ] },"linterOptions": {"exclude": ["./src/typings/**/*.d.ts" ] },"rulesDirectory": []}
Reference to the source project (Github)
Why do I get this error? How to fix it?