From 7e7261a7742e57dc1f91a439b1f45c53a3006347 Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Fri, 11 Oct 2024 13:52:48 +0200 Subject: [PATCH] first use of generics in a generator --- generators/angular/generator.ts | 10 ++++++++-- generators/angular/types.d.ts | 5 ++++- generators/client/types.d.ts | 2 -- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/generators/angular/generator.ts b/generators/angular/generator.ts index f5f200f86cf3..cba5f4911746 100644 --- a/generators/angular/generator.ts +++ b/generators/angular/generator.ts @@ -18,7 +18,7 @@ */ import chalk from 'chalk'; import { isFileStateModified } from 'mem-fs-editor/state'; - +import type { Entity } from '../../lib/types/application/entity.js'; import BaseApplicationGenerator from '../base-application/index.js'; import { GENERATOR_ANGULAR, GENERATOR_CLIENT, GENERATOR_LANGUAGES } from '../generator-list.js'; import { defaultLanguage } from '../languages/support/index.js'; @@ -32,6 +32,7 @@ import { } from '../client/support/index.js'; import { createNeedleCallback, mutateData } from '../base/support/index.js'; import { writeEslintClientRootConfigFile } from '../javascript/generators/eslint/support/tasks.js'; +import type { TaskTypes as DefaultTaskTypes } from '../../lib/types/application/tasks.js'; import { cleanupEntitiesFiles, postWriteEntitiesFiles, writeEntitiesFiles } from './entity-files-angular.js'; import { writeFiles } from './files-angular.js'; import cleanupOldFilesTask from './cleanup.js'; @@ -46,10 +47,15 @@ import { isTranslatedAngularFile, translateAngularFilesTransform, } from './support/index.js'; +import type { AngularApplication } from './types.js'; const { ANGULAR } = clientFrameworkTypes; -export default class AngularGenerator extends BaseApplicationGenerator { +export default class AngularGenerator extends BaseApplicationGenerator< + Entity, + AngularApplication, + DefaultTaskTypes +> { localEntities?: any[]; async beforeQueue() { diff --git a/generators/angular/types.d.ts b/generators/angular/types.d.ts index bb225f3cda1c..b88b53057932 100644 --- a/generators/angular/types.d.ts +++ b/generators/angular/types.d.ts @@ -1,3 +1,6 @@ +import type { Entity } from '../../lib/types/application/entity.js'; +import type { ApplicationType } from '../../lib/types/application/application.js'; + export type AngularApplication = { angularLocaleId: string; -}; +} & ApplicationType; diff --git a/generators/client/types.d.ts b/generators/client/types.d.ts index 35cf78e2b8f8..4aab32bf6ab7 100644 --- a/generators/client/types.d.ts +++ b/generators/client/types.d.ts @@ -1,5 +1,4 @@ import type { addIconImport, addItemToMenu, addRoute } from '../angular/support/needles.js'; -import type { AngularApplication } from '../angular/types.js'; import type { ExportApplicationPropertiesFromCommand } from '../../lib/command/index.js'; import type { CypressApplication } from '../cypress/types.js'; import type { JavaScriptApplication, JavaScriptSourceType } from '../javascript/types.js'; @@ -10,7 +9,6 @@ type ApplicationClientProperties = ExportApplicationPropertiesFromCommand