charlie-tango / react-umbraco

React components for working with Umbraco Headless
MIT License
5 stars 1 forks source link

Types augment breaks with TypeScript 5.5.x #10

Open thebuilder opened 1 month ago

thebuilder commented 1 month ago

The augment to the library is no longer able to correctly infer the contentType generated by openapi-typescript.

import { components } from '@/openapi/umbraco';

type ApiBlockItemModel = components['schemas']['ApiBlockItemModel'];

declare module '@charlietango/react-umbraco' {
  interface UmbracoBlockItemModel extends ApiBlockItemModel {}
}

Error

app/components/RichText.tsx:37:20 - error TS2339: Property 'contentType' does not exist on type '{ id: string; properties: { [key: string]: unknown; }; }'.

37   switch (content?.contentType) {
                      ~~~~~~~~~~~

It correctly augment the type, but it's unable to narrow contentType.

thebuilder commented 1 month ago

This might be related to using an older verision of openapi-typescript