我正试图为我的es6
应用程序生成一个激进的react
客户端,但是遇到以下babel
错误:
SyntaxError: /path/to/petstore/src/ApiClient.js: Support for the experimental syntax 'classProperties' isn't currently enabled (231:33):
我为达到这一点而采取的步骤:
swagger-codegen@2
swagger-codegen generate -i http://petstore.swagger.io/v2/swagger.json -l javascript -o ./petstore --additional-properties usePromises=true,useES6=true
生成swagger客户端import { PetApi } from '../../../../petstore/src';
我的应用程序的package.json
包含以下内容:
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.5.5",
"ajv": "^6.10.2",
"babel": "^6.23.0",
"fuzzysort": "^1.1.4",
"immutability-helper": "^3.0.0",
"lodash": "^4.17.11",
"moment": "^2.24.0",
"moment-timezone": "^0.5.25",
"normalizr": "^3.4.0",
"prop-types-defined": "^15.6.0",
"react": "^16.8.6",
"react-redux": "^7.1.0",
"react-scripts": "3.0.1",
"redux": "^4.0.1",
"redux-mock-store": "^1.5.3",
"redux-persist": "^5.10.0",
"redux-testkit": "^1.0.6",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"superagent": "^5.1.0"
},
"devDependencies": {}
我的应用程序的babel.config.js
:
module.exports = {
presets: [
'module:metro-react-native-babel-preset'
],
plugins: [
[
'@babel/plugin-proposal-class-properties',
{
'loose': true
}
]
]
};
我还尝试擦除node_modules
并用yarn
重新安装
我尝试遍历所有招摇的文件并将类属性更改为函数,这导致我遇到另一个错误:
TypeError: _petstore_src__WEBPACK_IMPORTED_MODULE_5__.PetApi.getPetByIdWithHttpInfo is not a function
当我尝试运行PetApi.getPetByIdWithHttpInfo(1)
让我知道是否需要其他信息。
谢谢