generator-jhipster: Entity with string "status" field breaks React reducers

Overview of the issue

If an entity contains a string field named status, webpack compilation of the reducer fails with an error:

ERROR in /private/tmp/jh/react/src/main/webapp/app/entities/foo/foo.reducer.ts
(103,12): Type 'AxiosPromise<any>' cannot be converted to type 'Promise<IFoo>'.

ERROR in /private/tmp/jh/react/src/main/webapp/app/entities/foo/foo.reducer.ts
(103,12): Type 'AxiosPromise<any>' cannot be converted to type 'Promise<IFoo>'.
  Types of property 'then' are incompatible.
    Type '<TResult1 = AxiosResponse<any>, TResult2 = never>(onfulfilled?: (value: AxiosResponse<any>) => TR...' is not comparable to type '<TResult1 = IFoo, TResult2 = never>(onfulfilled?: (value: IFoo) => TResult1 | PromiseLike<TResult...'.
      Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
        Types of parameters 'value' and 'value' are incompatible.
          Type 'AxiosResponse<any>' is not comparable to type 'IFoo'.
            Types of property 'status' are incompatible.
              Type 'number' is not comparable to type 'string'.

ERROR in /private/tmp/jh/react/src/main/webapp/app/entities/foo/foo.reducer.ts
(110,14): Type 'AxiosPromise<any>' cannot be converted to type 'Promise<IFoo>'.
Motivation for or Use Case

This should work out of the box

Reproduce the error

Generate a React project and the entity with the following JDL:

entity Foo {
    status String
}
Suggest a Fix

Not sure why this happens, it doesn’t affect entities without a string status field. The part of the error that says Type 'number' is not comparable to type 'string' makes me guess it’s a conflict between the http status field and the entity status field?

JHipster Version(s)

v5-beta master 198234c9e4da659c69eb37edc8987d48e7219b0c

JHipster configuration
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.mycompany.myapp",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "5.0.0-beta.0",
    "baseName": "react",
    "reactive": false,
    "packageName": "com.mycompany.myapp",
    "packageFolder": "com/mycompany/myapp",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "replaced-by-jhipster-info",
    "clientFramework": "react",
    "useSass": false,
    "clientPackageManager": "yarn",
    "applicationType": "monolith",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": [
      "en"
    ]
  }
}
Entity configuration(s) entityName.json files generated in the .jhipster directory
entity Foo {
    status String
}
Environment and Tools
Environment and Tools

java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

git version 2.17.0

node: v8.9.3

npm: 5.6.0

yeoman: 2.0.0

yarn: 1.3.2

Docker version 18.04.0-ce, build 3d479c0

docker-compose version 1.21.0, build 5920eb0

  • Checking this box is mandatory (this is just to show you read everything)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 31 (31 by maintainers)

Commits related to this issue

Most upvoted comments

Argh !!! This is a tough one. We have status all over the place in our model: on our invoices, quotations, documents… I wanted to re-generate our JDL with JHipster 5 Beta 1 and got

The JDL is being parsed.
IllegalNameException: The name 'status' is a reserved keyword and can not be used as entity field name.

Are you sure to add status as a keyword ? JHipster aggregates several technologies and all of them have their keyword. So I think we should be careful about the keywords added in JHipster.