Repository: jhipster/jhipster-lite
Pull request #10464 (2024-07-31 09:22:07)

Simplify generated tsconfig for vue and react
Preparation for https://github.com/jhipster/jhipster-lite/issues/10421

murdos: Blocked by #10466

Patch:
diff --git a/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java b/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java
index 2f6edc083..bd339946f 100644
--- a/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java
+++ b/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java
@@ -42,6 +42,7 @@ public class ReactCoreModulesFactory {
         .addDevDependency(packageName("@types/node"), COMMON)
         .addDevDependency(packageName("@types/react"), REACT)
         .addDevDependency(packageName("@types/react-dom"), REACT)
+        .addDevDependency(packageName("@tsconfig/vite-react"), REACT)
         .addDevDependency(packageName("@typescript-eslint/eslint-plugin"), COMMON)
         .addDevDependency(packageName("@vitejs/plugin-react"), REACT)
         .addDevDependency(packageName("@vitest/coverage-istanbul"), COMMON)
diff --git a/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java b/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java
index fee02784f..1e7547205 100644
--- a/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java
+++ b/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java
@@ -58,6 +58,7 @@ public class VueModulesFactory {
         .addDevDependency(packageName("@vue/eslint-config-typescript"), VUE)
         .addDevDependency(packageName("@vue/eslint-config-prettier"), VUE)
         .addDevDependency(packageName("@vue/test-utils"), VUE)
+        .addDevDependency(packageName("@vue/tsconfig"), VUE)
         .addDevDependency(packageName("@vitest/coverage-istanbul"), COMMON)
         .addDevDependency(packageName("eslint"), COMMON)
         .addDevDependency(packageName("eslint-plugin-vue"), VUE)
diff --git a/src/main/resources/generator/client/pagination/domain/Page.ts.mustache b/src/main/resources/generator/client/pagination/domain/Page.ts.mustache
index 0983280f1..7e906342a 100755
--- a/src/main/resources/generator/client/pagination/domain/Page.ts.mustache
+++ b/src/main/resources/generator/client/pagination/domain/Page.ts.mustache
@@ -1,4 +1,4 @@
-import { DisplayedOnPage } from './DisplayedOnPage';
+import type { DisplayedOnPage } from './DisplayedOnPage';
 
 export type Page<Content> = {
   currentPage: number;
diff --git a/src/main/resources/generator/client/pagination/secondary/RestPage.ts.mustache b/src/main/resources/generator/client/pagination/secondary/RestPage.ts.mustache
index 031b1735f..0f675ce0c 100755
--- a/src/main/resources/generator/client/pagination/secondary/RestPage.ts.mustache
+++ b/src/main/resources/generator/client/pagination/secondary/RestPage.ts.mustache
@@ -1,4 +1,4 @@
-import { Page } from '@/shared/pagination/domain/Page';
+import type { Page } from '@/shared/pagination/domain/Page';
 
 export type RestData<T> = {
   data: T;
diff --git a/src/main/resources/generator/client/react/tsconfig.json b/src/main/resources/generator/client/react/tsconfig.json
index e2084baf9..dfb2b0b2e 100644
--- a/src/main/resources/generator/client/react/tsconfig.json
+++ b/src/main/resources/generator/client/react/tsconfig.json
@@ -1,28 +1,15 @@
 {
+  "extends": "@tsconfig/vite-react/tsconfig.json",
   "compilerOptions": {
-    "target": "ESNext",
-    "useDefineForClassFields": true,
-    "lib": ["DOM", "DOM.Iterable", "ESNext"],
-    "allowJs": false,
-    "skipLibCheck": true,
-    "esModuleInterop": false,
     "allowSyntheticDefaultImports": true,
-    "strict": true,
     "forceConsistentCasingInFileNames": true,
-    "resolveJsonModule": true,
-    "isolatedModules": true,
-    "noEmit": true,
-    "jsx": "react-jsx",
     "composite": false,
-    "module": "esnext",
-    "moduleResolution": "node",
-    "baseUrl": "src",
+    "baseUrl": ".",
     "types": ["vitest/globals"],
     "paths": {
-      "@/*": ["main/webapp/app/*"],
-      "@assets/*": ["main/webapp/assets/*"]
+      "@/*": ["src/main/webapp/app/*"],
+      "@assets/*": ["src/main/webapp/assets/*"]
     }
   },
-  "include": ["vite.config.ts", "src"],
-  "exclude": ["src/test/javascript/integration/**/*spec.ts", "node_modules"]
+  "include": ["src/main/webapp/**/*", "src/test/javascript/spec/**/*"]
 }
diff --git a/src/main/resources/generator/client/vue/tsconfig.json b/src/main/resources/generator/client/vue/tsconfig.json
index 39819fba5..684aae372 100644
--- a/src/main/resources/generator/client/vue/tsconfig.json
+++ b/src/main/resources/generator/client/vue/tsconfig.json
@@ -1,30 +1,13 @@
 {
+  "extends": "@vue/tsconfig/tsconfig.dom.json",
   "compilerOptions": {
-    "target": "esnext",
-    "useDefineForClassFields": true,
-    "module": "esnext",
-    "moduleResolution": "node",
-    "strict": true,
-    "jsx": "preserve",
-    "skipLibCheck": true,
     "allowJs": true,
     "sourceMap": true,
-    "resolveJsonModule": true,
-    "esModuleInterop": true,
-    "lib": ["esnext", "dom"],
     "types": ["vite/client", "vitest/globals"],
     "baseUrl": ".",
     "paths": {
       "@/*": ["src/main/webapp/app/*"]
     }
   },
-  "include": [
-    "src/main/webapp/**/*.ts",
-    "src/main/webapp/**/*.d.ts",
-    "src/main/webapp/**/*.tsx",
-    "src/main/webapp/**/*.vue",
-    "src/test/javascript/spec/**/*.ts",
-    "src/test/javascript/spec/**/*.vue"
-  ],
-  "exclude": ["./node_modules"]
+  "include": ["src/main/webapp/**/*", "src/test/javascript/spec/**/*"]
 }
diff --git a/src/main/resources/generator/client/vue/webapp/app/common/domain/Logger.ts.mustache b/src/main/resources/generator/client/vue/webapp/app/common/domain/Logger.ts.mustache
index d20ea3a03..b28a8d27a 100644
--- a/src/main/resources/generator/client/vue/webapp/app/common/domain/Logger.ts.mustache
+++ b/src/main/resources/generator/client/vue/webapp/app/common/domain/Logger.ts.mustache
@@ -1,4 +1,4 @@
-import { Message } from '@/common/domain/Message';
+import type { Message } from '@/common/domain/Message';
 
 export interface Logger {
   error(message: Message, error: Error): void;
diff --git a/src/main/resources/generator/client/vue/webapp/app/common/secondary/ConsoleLogger.ts.mustache b/src/main/resources/generator/client/vue/webapp/app/common/secondary/ConsoleLogger.ts.mustache
index f7996b9c5..8839fefa4 100644
--- a/src/main/resources/generator/client/vue/webapp/app/common/secondary/ConsoleLogger.ts.mustache
+++ b/src/main/resources/generator/client/vue/webapp/app/common/secondary/ConsoleLogger.ts.mustache
@@ -1,5 +1,5 @@
-import { Logger } from '@/common/domain/Logger';
-import { Message } from '@/common/domain/Message';
+import type { Logger } from '@/common/domain/Logger';
+import type { Message } from '@/common/domain/Message';
 
 export default class ConsoleLogger implements Logger {
   constructor(private readonly logger: Console) {}
diff --git a/src/main/resources/generator/client/vue/webapp/app/http/AxiosHttp.ts.mustache b/src/main/resources/generator/client/vue/webapp/app/http/AxiosHttp.ts.mustache
index 3801c5937..ec1033a20 100644
--- a/src/main/resources/generator/client/vue/webapp/app/http/AxiosHttp.ts.mustache
+++ b/src/main/resources/generator/client/vue/webapp/app/http/AxiosHttp.ts.mustache
@@ -1,4 +1,4 @@
-import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
+import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
 
 export type AxiosHttpResponse<T> = AxiosResponse<T>;
 
diff --git a/src/main/resources/generator/client/vue/webapp/app/vue/VueProp.ts b/src/main/resources/generator/client/vue/webapp/app/vue/VueProp.ts
index e4fc34007..796e322bb 100644
--- a/src/main/resources/generator/client/vue/webapp/app/vue/VueProp.ts
+++ b/src/main/resources/generator/client/vue/webapp/app/vue/VueProp.ts
@@ -1,4 +1,4 @@
-import { PropType } from 'vue';
+import type { PropType } from 'vue';
 
 export const objectType = <T>() => Object as PropType<T>;
 export const arrayType = <T>() => Array as PropType<T[]>;
diff --git a/src/main/resources/generator/dependencies/react/package.json b/src/main/resources/generator/dependencies/react/package.json
index 8a4d13845..33b08e4d1 100644
--- a/src/main/resources/generator/dependencies/react/package.json
+++ b/src/main/resources/generator/dependencies/react/package.json
@@ -14,6 +14,7 @@
   "devDependencies": {
     "@testing-library/dom": "10.4.0",
     "@testing-library/react": "16.0.0",
+    "@tsconfig/vite-react": "3.0.2",
     "@types/react": "18.3.3",
     "@types/react-dom": "18.3.0",
     "@vitejs/plugin-react": "4.3.1",
diff --git a/src/main/resources/generator/dependencies/vue/package.json b/src/main/resources/generator/dependencies/vue/package.json
index 7386b10e8..e657450f3 100644
--- a/src/main/resources/generator/dependencies/vue/package.json
+++ b/src/main/resources/generator/dependencies/vue/package.json
@@ -17,6 +17,7 @@
     "@vue/eslint-config-prettier": "9.0.0",
     "@vue/eslint-config-typescript": "13.0.0",
     "@vue/test-utils": "2.4.6",
+    "@vue/tsconfig": "0.5.1",
     "eslint-plugin-vue": "9.27.0",
     "sinon": "18.0.0",
     "vue-tsc": "2.0.29"


Test patch:
diff --git a/src/test/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.java
index d92514f3f..7b845c9a5 100644
--- a/src/test/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.java
+++ b/src/test/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.java
@@ -26,6 +26,7 @@ class ReactCoreModulesFactoryTest {
       .containing(nodeDependency("@types/node"))
       .containing(nodeDependency("@types/react"))
       .containing(nodeDependency("@types/react-dom"))
+      .containing(nodeDependency("@tsconfig/vite-react"))
       .containing(nodeDependency("@typescript-eslint/eslint-plugin"))
       .containing(nodeDependency("@vitejs/plugin-react"))
       .containing(nodeDependency("@vitest/coverage-istanbul"))
diff --git a/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java
index 600b87f5a..82ebedbc0 100644
--- a/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java
+++ b/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java
@@ -33,6 +33,7 @@ class VueModulesFactoryTest {
         .containing(nodeDependency("@vue/eslint-config-typescript"))
         .containing(nodeDependency("@vue/eslint-config-prettier"))
         .containing(nodeDependency("@vue/test-utils"))
+        .containing(nodeDependency("@vue/tsconfig"))
         .containing(nodeDependency("@vitest/coverage-istanbul"))
         .containing(nodeDependency("eslint"))
         .containing(nodeDependency("eslint-plugin-vue"))