From 512c30908d0f56151f61912df60cbf1859c5b138 Mon Sep 17 00:00:00 2001 From: Fredrik Liljegren Date: Mon, 6 Oct 2025 15:20:53 +0200 Subject: [PATCH] feat: Adding RequiredProp type helper --- packages/js-lib/src/typeFest.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/js-lib/src/typeFest.ts b/packages/js-lib/src/typeFest.ts index bf11af15..8cf24f1f 100644 --- a/packages/js-lib/src/typeFest.ts +++ b/packages/js-lib/src/typeFest.ts @@ -197,6 +197,21 @@ export type ConditionalExcept = Except = Pick> +/** + Makes one property of T required instead of optional. + @example + ``` + import {RequireProp} from 'type-fest'; + interface Example { + a?: string + b?: string + }; + type ExampleA = RequireProp; + //=> {a: string; b?: string}; + ``` + */ +export type RequireProp = Required> & T + /** Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`. */