From 7f1f1770e9e1d6f4fd9329916dbc59b8daf35f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Wed, 31 Jul 2024 11:10:11 +0200 Subject: [PATCH 1/2] feat(vue): simplify tsconfig by using @vue/tsconfig dev dependency --- .../vue/core/domain/VueModulesFactory.java | 1 + .../client/pagination/domain/Page.ts.mustache | 2 +- .../pagination/secondary/RestPage.ts.mustache | 2 +- .../generator/client/vue/tsconfig.json | 21 ++----------------- .../app/common/domain/Logger.ts.mustache | 2 +- .../secondary/ConsoleLogger.ts.mustache | 4 ++-- .../vue/webapp/app/http/AxiosHttp.ts.mustache | 2 +- .../client/vue/webapp/app/vue/VueProp.ts | 2 +- .../generator/dependencies/vue/package.json | 1 + .../core/domain/VueModulesFactoryTest.java | 1 + 10 files changed, 12 insertions(+), 26 deletions(-) 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 fee02784f64..1e754720576 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 JHipsterModule buildVueModule(JHipsterModuleProperties properties) { .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 0983280f1de..7e906342a15 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 = { 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 031b1735f96..0f675ce0cfc 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 = { data: T; diff --git a/src/main/resources/generator/client/vue/tsconfig.json b/src/main/resources/generator/client/vue/tsconfig.json index 39819fba5ca..684aae37209 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 d20ea3a03ad..b28a8d27a1e 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 f7996b9c53f..8839fefa425 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 3801c5937be..ec1033a2020 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 = AxiosResponse; 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 e4fc34007c5..796e322bbd9 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 = () => Object as PropType; export const arrayType = () => Array as PropType; diff --git a/src/main/resources/generator/dependencies/vue/package.json b/src/main/resources/generator/dependencies/vue/package.json index 7386b10e8dc..e657450f380 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" 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 600b87f5a41..82ebedbc0e1 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 @@ void shouldCreateVueModule() { .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")) From 59bf425ddc94aed54f4c94620b636084f457db6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Wed, 31 Jul 2024 11:20:02 +0200 Subject: [PATCH 2/2] feat(react): simplify tsconfig by using @tsconfig/vite-react dev dependency --- .../core/domain/ReactCoreModulesFactory.java | 1 + .../generator/client/react/tsconfig.json | 23 ++++--------------- .../generator/dependencies/react/package.json | 1 + .../domain/ReactCoreModulesFactoryTest.java | 1 + 4 files changed, 8 insertions(+), 18 deletions(-) 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 2f6edc083f7..bd339946fe3 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 JHipsterModule buildModule(JHipsterModuleProperties properties) { .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/resources/generator/client/react/tsconfig.json b/src/main/resources/generator/client/react/tsconfig.json index e2084baf902..dfb2b0b2e7c 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/dependencies/react/package.json b/src/main/resources/generator/dependencies/react/package.json index 8a4d13845b8..33b08e4d183 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/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 d92514f3fa7..7b845c9a50c 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 @@ void shouldBuildModuleWithStyle() { .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"))