From 509cbdba9b17dfaca4b46a224e8fb3eb71e11999 Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Sat, 14 Oct 2023 11:45:36 +0200 Subject: [PATCH] Fixed typescript name --- src/types/collections.ts | 22 +++++++++++----------- src/utils/collectionConfig.ts | 3 ++- src/utils/string.ts | 2 ++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/types/collections.ts b/src/types/collections.ts index 1d5fc47..86c9639 100644 --- a/src/types/collections.ts +++ b/src/types/collections.ts @@ -694,22 +694,22 @@ declare module 'payload' { collections: { 'library-items': LibraryItem 'contents': Content - 'contents-folders': Contents Folder + 'contents-folders': ContentsFolder 'posts': Post 'chronology-items': ChronologyItem - 'chronology-eras': Chronology Era + 'chronology-eras': ChronologyEra 'weapons': Weapon - 'weapons-groups': Weapons Group - 'weapons-thumbnails': Weapons Thumbnail - 'contents-thumbnails': Contents Thumbnail - 'library-items-thumbnails': Library Item Thumbnail - 'library-items-scans': Library Item Scans - 'library-items-gallery': Library Item Gallery - 'recorders-thumbnails': Recorders Thumbnail - 'posts-thumbnails': Post Thumbnail + 'weapons-groups': WeaponsGroup + 'weapons-thumbnails': WeaponsThumbnail + 'contents-thumbnails': ContentsThumbnail + 'library-items-thumbnails': LibraryItemThumbnail + 'library-items-scans': LibraryItemScans + 'library-items-gallery': LibraryItemGallery + 'recorders-thumbnails': RecordersThumbnail + 'posts-thumbnails': PostThumbnail 'files': File 'videos': Video - 'videos-channels': Videos Channel + 'videos-channels': VideosChannel 'languages': Language 'currencies': Currency 'recorders': Recorder diff --git a/src/utils/collectionConfig.ts b/src/utils/collectionConfig.ts index 178c34a..91695ba 100644 --- a/src/utils/collectionConfig.ts +++ b/src/utils/collectionConfig.ts @@ -1,5 +1,6 @@ import { CollectionConfig } from "payload/types"; import { Collections } from "../constants"; +import { formatToPascalCase } from "./string"; type CollectionConfigWithPlugins = CollectionConfig; @@ -13,5 +14,5 @@ export type BuildCollectionConfig = Omit< export const buildCollectionConfig = (config: BuildCollectionConfig): CollectionConfig => ({ ...config, - typescript: { interface: config.labels.singular }, + typescript: { interface: formatToPascalCase(config.labels.singular) }, }); diff --git a/src/utils/string.ts b/src/utils/string.ts index dd779b6..c1a79a8 100644 --- a/src/utils/string.ts +++ b/src/utils/string.ts @@ -19,3 +19,5 @@ export const formatToCamelCase = (name: string): string => .split(/[ \_-]/g) .map((part, index) => (index > 0 ? capitalize(part) : part)) .join(""); + +export const formatToPascalCase = (name: string): string => capitalize(formatToCamelCase(name));