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

How can I use the classic Omit functionality applied to an array type instead of a type? #754

Closed
silversonicaxel opened this issue Nov 15, 2023 · 2 comments

Comments

@silversonicaxel
Copy link

silversonicaxel commented Nov 15, 2023

How can I use the classic Omit functionality applied to an array type instead of a type?

For example, I've the following type

type Car = {
  a: number,
  b: string,
  c: Record<string, unknown> | null
}

type Cars = Car[]

I would like to create similar types without c: Record<string, unknown> | null.

For example I could declare.

type Voiture = Omit<Car, 'c'>

type Voitures = Omit<Cars, 'c'>  // obviously not working

For code constraints, I ca't use Omit<Car, 'c'>[].

Is there a solution for this?

Thanks

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

Apply the Omit before making it an array, or wait for #576

@silversonicaxel
Copy link
Author

Oh, I found out
type Voitures = Omit<Cars[number], 'c'>[]

Thanks anyway

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

No branches or pull requests

2 participants