simplify extension registry generics

This commit is contained in:
Niels Lyngsø
2024-02-23 00:22:45 +01:00
parent 10f28c3db1
commit 40e4377f56
2 changed files with 5 additions and 4 deletions

View File

@@ -11,8 +11,8 @@ import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
/**
*/
export class UmbExtensionsElementInitializer<
ManifestTypes extends ManifestBase,
ManifestTypeName extends string = ManifestTypes['type'],
ManifestTypes extends ManifestBase = ManifestBase,
ManifestTypeName extends string = string,
ManifestType extends ManifestBase = SpecificManifestTypeOrManifestBase<ManifestTypes, ManifestTypeName>,
ControllerType extends UmbExtensionElementInitializer<ManifestType> = UmbExtensionElementInitializer<ManifestType>,
MyPermittedControllerType extends ControllerType = PermittedControllerType<ControllerType>,

View File

@@ -1,6 +1,6 @@
import type { ManifestBase } from './manifest-base.interface.js';
export type ManifestTypeMap<ManifestTypes extends ManifestBase> = {
type ManifestTypeMapGenerator<ManifestTypes extends ManifestBase> = {
[Manifest in ManifestTypes as Manifest['type']]: Manifest;
} & {
[key: string]: ManifestBase;
@@ -9,4 +9,5 @@ export type ManifestTypeMap<ManifestTypes extends ManifestBase> = {
export type SpecificManifestTypeOrManifestBase<
ManifestTypes extends ManifestBase,
T extends string,
> = T extends keyof ManifestTypeMap<ManifestTypes> ? ManifestTypeMap<ManifestTypes>[T] : ManifestBase;
ManifestTypeMapType = ManifestTypeMapGenerator<ManifestTypes>,
> = T extends keyof ManifestTypeMapType ? ManifestTypeMapType[T] : ManifestBase;