diff --git a/src/item/itemSettings.ts b/src/item/itemSettings.ts index fcec8893..03e09acc 100644 --- a/src/item/itemSettings.ts +++ b/src/item/itemSettings.ts @@ -3,6 +3,7 @@ import { OldCCLicenseAdaptations, } from '@/enums/ccLicenses.js'; import { DescriptionPlacementType } from '@/enums/descriptionPlacement.js'; +import { Nullable } from '@/typeUtils.js'; export interface ItemSettings { /** @deprecated use item.lang */ @@ -15,10 +16,12 @@ export interface ItemSettings { enableSaveActions?: boolean; tags?: string[]; displayCoEditors?: boolean; - ccLicenseAdaption?: + // allow null to delete setting in the backend + ccLicenseAdaption?: Nullable< | `${CCLicenseAdaptions}` | CCLicenseAdaptions // TODO: these are the old licenses, we might remove them at some point. - | `${OldCCLicenseAdaptations}`; + | `${OldCCLicenseAdaptations}` + >; descriptionPlacement?: DescriptionPlacementType; } diff --git a/src/typeUtils.ts b/src/typeUtils.ts index 67b45cbf..e406a638 100644 --- a/src/typeUtils.ts +++ b/src/typeUtils.ts @@ -29,9 +29,23 @@ export type AnyOf = { [K in keyof T]: Pick; }[keyof T]; -// TODO: add usage informations - /** * This allow to define a type with at least one attribute of T that is not a key in E. + * + * The following type add usage informations about: + * `type ShortLinkPatchPayload = AnyOfExcept;` + * - The `itemId` is not allowed. + * - All other attributes of ShortLinkPostPayload are allowed and optional. + * - At least of attribute is required. */ export type AnyOfExcept = AnyOf>; + +/** + * The type is T or null. + * + * - `type NullableString = Nullable`: + * - `const nullableString: NullableString = "my string";` + * - `const nullableString: NullableString = null;` + * - `type NullableMultipleType = Nullable`: + */ +export type Nullable = T | null;