jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.46k stars 4.02k forks source link

Typescript exception during gateway project creation #19039

Closed artyomsv closed 2 years ago

artyomsv commented 2 years ago
Overview of the issue

Execute jhipster cli tool to generate a gateway application but got a TypeScript exception during project generation

ERROR! Error parsing file src/main/webapp/app/modules/administration/administration.reducer.ts: SyntaxError: Declaration or statement expected. (36:7)
  34 |         };
  35 |       });
> 36 |       .addMatcher(
     |       ^
  37 |         isPending(
  38 |           getGatewayRoutes,
  39 |         ),

At: 1: import axios from 'axios';
2: import { createAsyncThunk, createSlice, isPending, isRejected } from '@reduxjs/toolkit';
3:
4: import { serializeAxiosError } from 'app/shared/reducers/reducer.utils';
5: import { AppThunk } from 'app/config/store';
6:
7: const initialState = {
8:   loading: false,
9:   errorMessage: null,
10:   gateway: {
11:     routes: []
12:   },
13:   totalItems: 0
14: };
15:
16: export type AdministrationState =  Readonly<typeof initialState>;
17:
18: // Actions
19: export const getGatewayRoutes = createAsyncThunk('administration/fetch_gateway_route', async () => axios.get<any>('api/gateway/routes'), {
20:   serializeError: serializeAxiosError,
21: });
22:
23:
24: export const AdministrationSlice = createSlice({
25:   name: 'administration',
26:   initialState: initialState as AdministrationState,
27:   reducers: {
28:   },
29:   extraReducers(builder) {
30:     builder.addCase(getGatewayRoutes.fulfilled, (state, action) => {
31:         state.loading = false;
32:         state.gateway = {
33:           routes: action.payload.data
34:         };
35:       });
36:       .addMatcher(
37:         isPending(
38:           getGatewayRoutes,
39:         ),
40:         state => {
41:           state.errorMessage = null;
42:           state.loading = true;
43:         }
44:       )
45:       .addMatcher(
46:         isRejected(
47:           getGatewayRoutes,
48:         ),
49:         (state, action) => {
50:           state.errorMessage = action.error.message;
51:           state.loading = false;
52:         }
53:       );
54:   },
55: });
56:
57:
58: // Reducer
59: export default AdministrationSlice.reducer;
60:
Reproduce the error

run jhipster generator together with the provided .yo-rc.json

JHipster Version(s)

7.8.1

JHipster configuration
Welcome to JHipster v7.8.1

Welcome to the JHipster Information Sub-Generator

administratorwebui@0.0.1-SNAPSHOT /mnt/e/Projects/Tangram/tangram-be-documents/admin-web-ui
└── (empty)

##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**

<details>
<summary>.yo-rc.json file</summary>
<pre>
{
  "generator-jhipster": {
    "applicationType": "gateway",
    "authenticationType": "oauth2",
    "baseName": "administratorwebui",
    "blueprints": [],
    "buildTool": "maven",
    "cacheProvider": "no",
    "clientFramework": "react",
    "clientPackageManager": "npm",
    "clientTheme": "darkly",
    "clientThemeVariant": "dark",
    "creationTimestamp": 1656451785486,
    "databaseType": "no",
    "devDatabaseType": "no",
    "devServerPort": 9060,
    "dtoSuffix": "DTO",
    "enableGradleEnterprise": false,
    "enableHibernateCache": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": false,
    "entitySuffix": "",
    "jhiPrefix": "jhi",
    "jhipsterVersion": "7.8.1",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "languages": ["en"],
    "messageBroker": false,
    "monorepository": true,
    "nativeLanguage": "en",
    "otherModules": [],
    "packageName": "com.iptiq.tangram.web",
    "pages": [],
    "prodDatabaseType": "no",
    "reactive": true,
    "searchEngine": false,
    "serverPort": "8080",
    "serverSideOptions": [],
    "serviceDiscoveryType": "no",
    "skipCheckLengthOfIdentifier": false,
    "skipCommitHook": true,
    "skipFakeData": false,
    "skipUserManagement": true,
    "testFrameworks": [],
    "websocket": false,
    "withAdminUi": false
  }
}

</pre>
</details>

##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**

<details>
<summary>JDL entity definitions</summary>

<pre>

</pre>
</details>

##### **Environment and Tools**

openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment 18.9 (build 11.0.12+7)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7, mixed mode)

git version 2.25.1

node: v18.2.0

npm: 8.7.0

Docker version 19.03.13, build 4484c46d9d

Docker Compose version v2.6.0

No change to package.json was detected. No package manager install will be executed.
Congratulations, JHipster execution is complete!
Sponsored with ❤️  by @oktadev.
Browsers and Operating System

Windows with WSL2

mshima commented 2 years ago

https://github.com/jhipster/generator-jhipster/blob/b474b1ea960d604da6fa19fc06cac43acbec434c/generators/client/templates/react/src/main/webapp/app/modules/administration/administration.reducer.ts.ejs#L121-L123