Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PartialDeep doesn't work with arrays #893

Open
Mnigos opened this issue Jun 17, 2024 · 3 comments
Open

PartialDeep doesn't work with arrays #893

Mnigos opened this issue Jun 17, 2024 · 3 comments

Comments

@Mnigos
Copy link

Mnigos commented Jun 17, 2024

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

  • We're using Polar.sh so you can upvote and help fund this issue.
  • The funding will be given to active contributors.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@sindresorhus
Copy link
Owner

There is an option to recurse into arrays.

@Mnigos
Copy link
Author

Mnigos commented Jun 17, 2024

There is an option to recurse into arrays.

I think this should be mentioned in docs.

@bleistift-zwei
Copy link

The docs say,

By default, this does not affect elements in array and tuple types. You can change this by passing `{recurseIntoArrays: true}` as the second type argument:
```
import type {PartialDeep} from 'type-fest';
interface Settings {
languages: string[];
}
const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
languages: [undefined]
};
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants