From 18030b8bc0d29f08537488bc782c2d0793a0f8af Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 25 Feb 2025 09:30:15 +0100 Subject: [PATCH 1/2] rollup - fail when typescript has warnings or errors (#154) Currently this is detected when building the docu. Since the developer rarely does that the problem is detected on github. This change allows the developer to discover the error early by failing the build. --- rollup.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/rollup.config.js b/rollup.config.js index 33893a11..05dd097b 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -40,6 +40,7 @@ export default [ }), typescript({ tsconfig: './tsconfig.json', + noEmitOnError: true, }), svg({ base64: true }), ], From 1de44c3e1c03b81e2c8b816dfaf07f65d955f651 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 25 Feb 2025 09:39:09 +0100 Subject: [PATCH 2/2] feat(release): improve typing of itemsApi (WIP) (#148) * Improve typing of itemsApi * Show error if name of new item cannot be determined --------- Co-authored-by: Ulf Gebhardt Co-authored-by: Anton Tranelis <31516529+antontranelis@users.noreply.github.com> --- src/Components/Map/Subcomponents/ItemFormPopup.tsx | 9 ++++++++- src/Components/Map/hooks/useItems.tsx | 1 - src/types/LayerProps.d.ts | 3 +-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Components/Map/Subcomponents/ItemFormPopup.tsx b/src/Components/Map/Subcomponents/ItemFormPopup.tsx index ef191276..5a2ad79d 100644 --- a/src/Components/Map/Subcomponents/ItemFormPopup.tsx +++ b/src/Components/Map/Subcomponents/ItemFormPopup.tsx @@ -53,6 +53,13 @@ export function ItemFormPopup(props: ItemFormPopupProps) { }) formItem.position = { type: 'Point', coordinates: [props.position.lng, props.position.lat] } evt.preventDefault() + + const name = formItem.name ? formItem.name : user?.first_name + if (!name) { + toast.error('Name is must be defined') + return + } + setSpinner(true) formItem.text && @@ -98,8 +105,8 @@ export function ItemFormPopup(props: ItemFormPopupProps) { ;(!props.layer.userProfileLayer || !item) && (await props.layer.api?.createItem!({ ...formItem, + name, id: uuid, - name: formItem.name ? formItem.name : user?.first_name, })) success = true // eslint-disable-next-line no-catch-all/no-catch-all diff --git a/src/Components/Map/hooks/useItems.tsx b/src/Components/Map/hooks/useItems.tsx index bf8779fe..0fb1af78 100644 --- a/src/Components/Map/hooks/useItems.tsx +++ b/src/Components/Map/hooks/useItems.tsx @@ -82,7 +82,6 @@ function useItemsManager(initialItems: Item[]): { }, }) result.map((item) => { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment dispatch({ type: 'ADD', item: { ...item, layer } }) return null }) diff --git a/src/types/LayerProps.d.ts b/src/types/LayerProps.d.ts index 44f55a95..9c720bc4 100644 --- a/src/types/LayerProps.d.ts +++ b/src/types/LayerProps.d.ts @@ -18,8 +18,7 @@ export interface LayerProps { markerShape: string markerDefaultColor: string markerDefaultColor2?: string - // eslint-disable-next-line @typescript-eslint/no-explicit-any - api?: ItemsApi + api?: ItemsApi itemType: ItemType userProfileLayer?: boolean customEditLink?: string