swagger-codegen react client-实验语法'classProperties'错误

时间:2019-08-09 16:46:13

标签: reactjs ecmascript-6 swagger babel swagger-codegen

我正试图为我的es6应用程序生成一个激进的react客户端,但是遇到以下babel错误:

SyntaxError: /path/to/petstore/src/ApiClient.js: Support for the experimental syntax 'classProperties' isn't currently enabled (231:33):

我为达到这一点而采取的步骤:

  1. 使用自制软件安装swagger-codegen@2
  2. 使用swagger-codegen generate -i http://petstore.swagger.io/v2/swagger.json -l javascript -o ./petstore --additional-properties usePromises=true,useES6=true生成swagger客户端
  3. 添加到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)

让我知道是否需要其他信息。

谢谢

0 个答案:

没有答案