From 3d4236c7bdf01361534bc8dafa663e718562d35e Mon Sep 17 00:00:00 2001 From: Nathan Vasse Date: Thu, 18 Jan 2024 14:38:12 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F(react)=20add=20WithOption?= =?UTF-8?q?al=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This type allows to make only specific attributes optionnal where the existing Partial makes all the attributes optionnal. Its first use will be for Modals. --- packages/react/src/types/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react/src/types/index.ts b/packages/react/src/types/index.ts index 0404056..eaec8bf 100644 --- a/packages/react/src/types/index.ts +++ b/packages/react/src/types/index.ts @@ -5,3 +5,7 @@ export type PartialNested = { export type PartialExtendableNested = { [K in keyof T]?: T[K] extends object ? PartialExtendableNested : T[K]; } & Record; + +// From https://github.com/Microsoft/TypeScript/issues/25760#issuecomment-405931434. +export type WithOptional = Omit & + Partial>;