sindresorhus / type-fest

A collection of essential TypeScript types
Creative Commons Zero v1.0 Universal
13.59k stars 513 forks source link

`PartialDeep` doesn't work with arrays #893

Open Mnigos opened 2 weeks ago

Mnigos commented 2 weeks ago
import type { PartialDeep } from 'type-fest'

import type { TrackEntity } from '@app/api/types'

export const trackExample: PartialDeep<TrackEntity> = {
  name: 'In Search for New Wisdom',
  href: 'https://open.spotify.com/track/0QBcteLxmPLG4gAXc1pEqW',
  album: {
    images: [
      {
        height: 300,
        width: 300,
        url: 'https://i.scdn.co/image/ab67616d00001e02c84f17fc34c60240d9676c2f',
      },
    ],
  },
  artists: [
    {
      id: 'dec548ab-365f-4fe1-a2b9-c0ea52c9ff89',
      name: 'Eldamar',
    },
  ],
}
Type '{ id: string; name: string; }' is missing the following properties from type 'ArtistEntity': popularity, externalId, followers, genres, and 2 more.

Upvote & Fund

Fund with Polar

sindresorhus commented 2 weeks ago

There is an option to recurse into arrays.

Mnigos commented 2 weeks ago

There is an option to recurse into arrays.

I think this should be mentioned in docs.

bleistift-zwei commented 1 week ago

The docs say,

https://github.com/sindresorhus/type-fest/blob/dc35412b43c3dc15d7a50e1ad38bcc7f96716281/source/partial-deep.d.ts#L43-L55